WorkerThreadPool: Avoid most runtime allocations
Just a little optimization. **NOTE:** With `RID_Owner` we could replace each pair of `PagedAllocator` and `HashMap`-of-ids-to-pointers. However, that would force us to expose `RID` as the task/group id, instead of `int`, which would break the API. Too bad. Let's wait until Godot 5.0.
This commit is contained in:
@ -613,13 +613,14 @@ void WorkerThreadPool::finish() {
|
||||
return;
|
||||
}
|
||||
|
||||
task_mutex.lock();
|
||||
SelfList<Task> *E = low_priority_task_queue.first();
|
||||
while (E) {
|
||||
print_error("Task waiting was never re-claimed: " + E->self()->description);
|
||||
E = E->next();
|
||||
{
|
||||
MutexLock lock(task_mutex);
|
||||
SelfList<Task> *E = low_priority_task_queue.first();
|
||||
while (E) {
|
||||
print_error("Task waiting was never re-claimed: " + E->self()->description);
|
||||
E = E->next();
|
||||
}
|
||||
}
|
||||
task_mutex.unlock();
|
||||
|
||||
{
|
||||
MutexLock lock(task_mutex);
|
||||
@ -632,6 +633,13 @@ void WorkerThreadPool::finish() {
|
||||
data.thread.wait_to_finish();
|
||||
}
|
||||
|
||||
{
|
||||
MutexLock lock(task_mutex);
|
||||
for (KeyValue<TaskID, Task *> &E : tasks) {
|
||||
task_allocator.free(E.value);
|
||||
}
|
||||
}
|
||||
|
||||
threads.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user