MCPcopy Create free account
hub / github.com/cocos/cocos-engine / addThread

Method addThread

native/cocos/base/threading/ThreadPool.cpp:61–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void ThreadPool::addThread() {
62 CC_ASSERT(_workers.size() < MAX_THREAD_COUNT);
63
64 auto workerLoop = [this]() {
65 while (_running) {
66 Task task = nullptr;
67
68 if (_tasks.try_dequeue(task)) {
69 task();
70 } else {
71 // Double Check
72 _event.wait([this]() {
73 return _tasks.size_approx() != 0;
74 });
75 }
76 }
77 };
78
79 _workers.emplace_back(workerLoop);
80}
81
82} // namespace cc

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.65
waitMethod · 0.45

Tested by

no test coverage detected