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 | |
| ThreadPool & | operator= (const ThreadPool &)=delete |
| int | getWorkerCount () const |
| int | getPendingCount () const |
| bool | isRunning () const |
| Task * | submit (std::function< void()> fn) |
| Submit a C++ callable. Caller owns the Task wrapper; work owns its shared state. | |
| Task * | submitSleep (int ms) |
| Sleep on a worker, then mark done — useful from scripts / tests. | |
| Task * | submitPush (Channel *channel, std::string message, int delayMs=0) |
| Sleep, then push a message onto a channel (cross-thread signalling). | |
| Task * | 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. | |
| 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.h 第 24 行定义.
构造及析构函数说明
◆ ThreadPool() [1/2]
|
explicit |
在文件 ThreadPool.cpp 第 33 行定义.
引用了 state.
◆ ~ThreadPool()
| eve::thread::ThreadPool::~ThreadPool | ( | ) |
在文件 ThreadPool.cpp 第 72 行定义.
◆ ThreadPool() [2/2]
|
delete |
成员函数说明
◆ getPendingCount()
| int eve::thread::ThreadPool::getPendingCount | ( | ) | const |
在文件 ThreadPool.cpp 第 81 行定义.
◆ getWorkerCount()
| int eve::thread::ThreadPool::getWorkerCount | ( | ) | const |
在文件 ThreadPool.cpp 第 79 行定义.
◆ isRunning()
| bool eve::thread::ThreadPool::isRunning | ( | ) | const |
在文件 ThreadPool.cpp 第 86 行定义.
◆ operator=()
|
delete |
◆ stop()
| void eve::thread::ThreadPool::stop | ( | ) |
Stop accepting work and join workers. Worker calls are rejected. Idempotent.
在文件 ThreadPool.cpp 第 164 行定义.
◆ 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.cpp 第 91 行定义.
被这些函数引用 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.cpp 第 134 行定义.
引用了 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.cpp 第 117 行定义.
引用了 submit().
◆ submitSleep()
| Task * eve::thread::ThreadPool::submitSleep | ( | int | ms | ) |
Sleep on a worker, then mark done — useful from scripts / tests.
在文件 ThreadPool.cpp 第 109 行定义.
引用了 submit().
◆ waitAll()
| void eve::thread::ThreadPool::waitAll | ( | ) |
Block until idle. Throws when called by a worker belonging to this pool.
在文件 ThreadPool.cpp 第 156 行定义.
引用了 state.
该类的文档由以下文件生成:
- src/modules/thread/ThreadPool.h
- src/modules/thread/ThreadPool.cpp