载入中...
搜索中...
未找到
eve::thread::ThreadPool类 参考

Fixed-size worker pool. Owns worker std::threads; tasks run FIFO. Squirrel VM is not thread-safe — do not call into scripts from workers. 更多...

#include <ThreadPool.h>

struct  State
 

Public 成员函数

 ThreadPool (int workerCount)
 
 ~ThreadPool ()
 
 ThreadPool (const ThreadPool &)=delete
 
ThreadPooloperator= (const ThreadPool &)=delete
 
int getWorkerCount () const
 
int getPendingCount () const
 
bool isRunning () const
 
Tasksubmit (std::function< void()> fn)
 Submit a C++ callable. Caller owns the Task wrapper; work owns its shared state.
 
TasksubmitSleep (int ms)
 Sleep on a worker, then mark done — useful from scripts / tests.
 
TasksubmitPush (Channel *channel, std::string message, int delayMs=0)
 Sleep, then push a message onto a channel (cross-thread signalling).
 
TasksubmitPost (std::string name, std::string data="", int delayMs=0)
 Sleep, then post an Event on the main queue (thread-safe). Scripts poll via event.poll / event.pollData, or async helpers.
 
void waitAll ()
 Block until idle. Throws when called by a worker belonging to this pool.
 
void stop ()
 Stop accepting work and join workers. Worker calls are rejected. Idempotent.
 

详细描述

Fixed-size worker pool. Owns worker std::threads; tasks run FIFO. Squirrel VM is not thread-safe — do not call into scripts from workers.

在文件 ThreadPool.h24 行定义.

构造及析构函数说明

◆ ThreadPool() [1/2]

eve::thread::ThreadPool::ThreadPool ( int  workerCount)
explicit

在文件 ThreadPool.cpp33 行定义.

引用了 state.

◆ ~ThreadPool()

eve::thread::ThreadPool::~ThreadPool ( )

在文件 ThreadPool.cpp72 行定义.

◆ ThreadPool() [2/2]

eve::thread::ThreadPool::ThreadPool ( const ThreadPool )
delete

成员函数说明

◆ getPendingCount()

int eve::thread::ThreadPool::getPendingCount ( ) const

在文件 ThreadPool.cpp81 行定义.

◆ getWorkerCount()

int eve::thread::ThreadPool::getWorkerCount ( ) const

在文件 ThreadPool.cpp79 行定义.

◆ isRunning()

bool eve::thread::ThreadPool::isRunning ( ) const

在文件 ThreadPool.cpp86 行定义.

◆ operator=()

ThreadPool & eve::thread::ThreadPool::operator= ( const ThreadPool )
delete

◆ stop()

void eve::thread::ThreadPool::stop ( )

Stop accepting work and join workers. Worker calls are rejected. Idempotent.

在文件 ThreadPool.cpp164 行定义.

◆ submit()

Task * eve::thread::ThreadPool::submit ( std::function< void()>  fn)

Submit a C++ callable. Caller owns the Task wrapper; work owns its shared state.

在文件 ThreadPool.cpp91 行定义.

引用了 fn , 以及 state.

被这些函数引用 submitPost(), submitPush() , 以及 submitSleep().

◆ submitPost()

Task * eve::thread::ThreadPool::submitPost ( std::string  name,
std::string  data = "",
int  delayMs = 0 
)

Sleep, then post an Event on the main queue (thread-safe). Scripts poll via event.poll / event.pollData, or async helpers.

在文件 ThreadPool.cpp134 行定义.

引用了 data, name, eve::cap::query() , 以及 submit().

◆ submitPush()

Task * eve::thread::ThreadPool::submitPush ( Channel channel,
std::string  message,
int  delayMs = 0 
)

Sleep, then push a message onto a channel (cross-thread signalling).

在文件 ThreadPool.cpp117 行定义.

引用了 submit().

◆ submitSleep()

Task * eve::thread::ThreadPool::submitSleep ( int  ms)

Sleep on a worker, then mark done — useful from scripts / tests.

在文件 ThreadPool.cpp109 行定义.

引用了 submit().

◆ waitAll()

void eve::thread::ThreadPool::waitAll ( )

Block until idle. Throws when called by a worker belonging to this pool.

在文件 ThreadPool.cpp156 行定义.

引用了 state.


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