| 252 | } |
| 253 | |
| 254 | void 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 | |
| 275 | void LegacyThreadPool::joinThread(int tid) { |
| 276 | if (tid < 0 || tid >= (int)_threads.size()) { |