Skip to content

Translated comments for PR #245 #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Network/sockutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,15 +686,18 @@ bool check_ip(string &address, const string &ip) {
//A类私有IP地址: [AUTO-TRANSLATED:ef542777]
//A-class private IP address:
//10.0.0.0~10.255.255.255 [AUTO-TRANSLATED:dbbf8c5f]
//10.0.0.0~10.255.255.255
// 10.0.0.0~10.255.255.255 [AUTO-TRANSLATED:dbbf8c5f]
// 10.0.0.0~10.255.255.255
//B类私有IP地址: [AUTO-TRANSLATED:7dfef625]
//B-class private IP address:
//172.16.0.0~172.31.255.255 [AUTO-TRANSLATED:a96262fa]
//172.16.0.0~172.31.255.255
// 172.16.0.0~172.31.255.255 [AUTO-TRANSLATED:a96262fa]
// 172.16.0.0~172.31.255.255
//C类私有IP地址: [AUTO-TRANSLATED:dc37505e]
//C-class private IP address:
//192.168.0.0~192.168.255.255 [AUTO-TRANSLATED:c8c47e43]
//192.168.0.0~192.168.255.255
// 192.168.0.0~192.168.255.255 [AUTO-TRANSLATED:c8c47e43]
// 192.168.0.0~192.168.255.255
//如果是私有地址 说明在nat内部 [AUTO-TRANSLATED:92007abb]
//If it's a private address, it's inside the NAT

Expand Down
40 changes: 30 additions & 10 deletions src/Poller/EventPoller.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,50 +283,70 @@ class EventPoller : public TaskExecutor, public AnyStorage, public std::enable_s

private:
//标记loop线程是否退出 [AUTO-TRANSLATED:98250f84]
//标记loop线程是否退出
// 标记loop线程是否退出 [AUTO-TRANSLATED:98250f84]
// 标记loop线程是否退出
// Mark the loop thread as exited
// Mark the loop thread as exited
bool _exit_flag;
//线程名 [AUTO-TRANSLATED:f1d62d9f]
//线程名
// 线程名 [AUTO-TRANSLATED:f1d62d9f]
// 线程名
// Thread name
// Thread name
std::string _name;
//当前线程下,所有socket共享的读缓存 [AUTO-TRANSLATED:6ce70017]
//当前线程下,所有socket共享的读缓存
// 当前线程下,所有socket共享的读缓存 [AUTO-TRANSLATED:6ce70017]
// 当前线程下,所有socket共享的读缓存
// Shared read buffer for all sockets under the current thread
// Shared read buffer for all sockets under the current thread
std::weak_ptr<SocketRecvBuffer> _shared_buffer[2];
//执行事件循环的线程 [AUTO-TRANSLATED:2465cc75]
//执行事件循环的线程
// 执行事件循环的线程 [AUTO-TRANSLATED:2465cc75]
// 执行事件循环的线程
// Thread that executes the event loop
// Thread that executes the event loop
std::thread *_loop_thread = nullptr;
//通知事件循环的线程已启动 [AUTO-TRANSLATED:61f478cf]
//通知事件循环的线程已启动
// 通知事件循环的线程已启动 [AUTO-TRANSLATED:61f478cf]
// 通知事件循环的线程已启动
// Notify the event loop thread that it has started
// Notify the event loop thread that it has started
semaphore _sem_run_started;

//内部事件管道 [AUTO-TRANSLATED:dc1d3a93]
//内部事件管道
// 内部事件管道 [AUTO-TRANSLATED:dc1d3a93]
// 内部事件管道
// Internal event pipe
// Internal event pipe
PipeWrap _pipe;
//从其他线程切换过来的任务 [AUTO-TRANSLATED:d16917d6]
//从其他线程切换过来的任务
// 从其他线程切换过来的任务 [AUTO-TRANSLATED:d16917d6]
// 从其他线程切换过来的任务
// Tasks switched from other threads
// Tasks switched from other threads
std::mutex _mtx_task;
List<Task::Ptr> _list_task;

//保持日志可用 [AUTO-TRANSLATED:4a6c2438]
//保持日志可用
// 保持日志可用 [AUTO-TRANSLATED:4a6c2438]
// 保持日志可用
// Keep the log available
// Keep the log available
Logger::Ptr _logger;

#if defined(HAS_EPOLL) || defined(HAS_KQUEUE)
// epoll和kqueue相关 [AUTO-TRANSLATED:84d2785e]
//epoll和kqueue相关
// epoll和kqueue相关 [AUTO-TRANSLATED:da2e77d9]
// epoll和kqueue相关
// Related to epoll and kqueue
// epoll and kqueue related
int _event_fd = -1;
std::unordered_map<int, std::shared_ptr<PollEventCB> > _event_map;
#else
// select相关 [AUTO-TRANSLATED:bf3e2edd]
//select相关
// select相关 [AUTO-TRANSLATED:d6f5b859]
// select相关
// Related to select
// select related
struct Poll_Record {
using Ptr = std::shared_ptr<Poll_Record>;
Expand Down
26 changes: 26 additions & 0 deletions src/Thread/TaskExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,18 @@ class TaskExecutorGetter {
/**
* 获取任务执行器
* @return 任务执行器
* Get task executor
* @return task executor

* [AUTO-TRANSLATED:49f1c782]
*/
virtual TaskExecutor::Ptr getExecutor() = 0;

/**
* 获取执行器个数
* Get the number of executors

* [AUTO-TRANSLATED:19813118]
*/
virtual size_t getExecutorSize() const = 0;
};
Expand All @@ -260,29 +267,48 @@ class TaskExecutorGetterImp : public TaskExecutorGetter {
/**
* 根据线程负载情况,获取最空闲的任务执行器
* @return 任务执行器
* Get the most idle task executor based on thread load
* @return task executor

* [AUTO-TRANSLATED:424dae60]
*/
TaskExecutor::Ptr getExecutor() override;

/**
* 获取所有线程的负载率
* @return 所有线程的负载率
* Get the load rate of all threads
* @return load rate of all threads

* [AUTO-TRANSLATED:99f44986]
*/
std::vector<int> getExecutorLoad();

/**
* 获取所有线程任务执行延时,单位毫秒
* 通过此函数也可以大概知道线程负载情况
* @return
* Get the task execution delay of all threads in milliseconds
* This function can also roughly determine the thread load
* @return

* [AUTO-TRANSLATED:f4045148]
*/
void getExecutorDelay(const std::function<void(const std::vector<int> &)> &callback);

/**
* 遍历所有线程
* Traverse all threads

* [AUTO-TRANSLATED:3ca5fb62]
*/
void for_each(const std::function<void(const TaskExecutor::Ptr &)> &cb);

/**
* 获取线程数
* Get the number of threads

* [AUTO-TRANSLATED:cf1903ce]
*/
size_t getExecutorSize() const override;

Expand Down
Loading