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

Method stopTasksByType

native/cocos/base/ThreadPool.cpp:254–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254void LegacyThreadPool::stopTasksByType(TaskType type) {
255 Task task;
256
257 ccstd::vector<Task> notStopTasks;
258 notStopTasks.reserve(_taskQueue.size());
259
260 while (_taskQueue.pop(task)) {
261 if (task.type == type) { // Delete the task from queue
262 delete task.callback;
263 } else { // If task type isn't match, push it into a vector, then insert to task queue again
264 notStopTasks.push_back(task);
265 }
266 }
267
268 if (!notStopTasks.empty()) {
269 for (const auto &t : notStopTasks) {
270 _taskQueue.push(t);
271 }
272 }
273}
274
275void LegacyThreadPool::joinThread(int tid) {
276 if (tid < 0 || tid >= (int)_threads.size()) {

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.65
push_backMethod · 0.65
reserveMethod · 0.45
popMethod · 0.45
emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected