VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::MultiLoop类 参考

Multi-threaded variant of MessageLoop running tasks on a worker-thread pool. 更多...

#include <multi_loop.h>

类 vlink::MultiLoop 继承关系图:
vlink::MultiLoop 的协作图:

Public 成员函数

 MultiLoop (size_t thread_num=4U)
 Constructs a MultiLoop with the default kNormalType queue and thread_num workers.
 MultiLoop (size_t thread_num, Type type)
 Constructs a MultiLoop with a specific queue type.
 ~MultiLoop () override
 Destructor. Quits the loop and joins all worker threads.
bool is_in_same_thread () const override
 Returns true if the calling thread is one of the worker threads.

Protected 成员函数

void on_begin () override
 Called once on each worker thread immediately after it starts.
void on_end () override
 Called once on each worker thread just before it exits.
void on_task_changed (Callback &&callback, uint32_t start_time) override
 Called on the worker thread executing the task, before the task runs.

额外继承的成员函数

 Queue implementation type. 更多...
 Idle strategy controlling CPU and latency trade-offs. 更多...
 Pre-defined task priority levels for kPriorityType loops. 更多...

详细描述

Multi-threaded variant of MessageLoop running tasks on a worker-thread pool.

All threads share the same task queue. Tasks are not guaranteed to execute in order.

构造及析构函数说明

◆ MultiLoop() [1/2]

vlink::MultiLoop::MultiLoop ( size_t thread_num = 4U)
explicit

Constructs a MultiLoop with the default kNormalType queue and thread_num workers.

参数
thread_numNumber of worker threads. Default: 4.
这是这个函数的调用关系图:

◆ MultiLoop() [2/2]

vlink::MultiLoop::MultiLoop ( size_t thread_num,
Type type )
explicit

Constructs a MultiLoop with a specific queue type.

参数
thread_numNumber of worker threads.
typeQueue implementation type (see MessageLoop::Type).

◆ ~MultiLoop()

vlink::MultiLoop::~MultiLoop ( )
override

Destructor. Quits the loop and joins all worker threads.

成员函数说明

◆ is_in_same_thread()

bool vlink::MultiLoop::is_in_same_thread ( ) const
nodiscardoverridevirtual

Returns true if the calling thread is one of the worker threads.

返回
true if called from any thread owned by this MultiLoop.

重载 vlink::MessageLoop .

◆ on_begin()

void vlink::MultiLoop::on_begin ( )
overrideprotectedvirtual

Called once on each worker thread immediately after it starts.

Override to perform per-thread initialisation (e.g., setting thread name or affinity).

重载 vlink::MessageLoop .

◆ on_end()

void vlink::MultiLoop::on_end ( )
overrideprotectedvirtual

Called once on each worker thread just before it exits.

Override to perform per-thread cleanup.

重载 vlink::MessageLoop .

◆ on_task_changed()

void vlink::MultiLoop::on_task_changed ( Callback && callback,
uint32_t start_time )
overrideprotectedvirtual

Called on the worker thread executing the task, before the task runs.

参数
callbackThe task about to be executed.
start_timeMillisecond timestamp at which the task was dequeued.

重载 vlink::MessageLoop .

函数调用图:

该类的文档由以下文件生成: