WorkerThreadPool: Refactor deadlock prevention collaboration into a generic mechanism

This is strictly beyond a refactor because it also changes when the mutexes are relocked,
but that's only for extra safety.
This commit is contained in:
Pedro J. Estébanez
2024-06-19 08:09:59 +02:00
parent e7dd6f11ed
commit 03d14e436b
3 changed files with 92 additions and 27 deletions

View File

@ -364,7 +364,7 @@ class CommandQueueMT {
lock();
WorkerThreadPool::thread_enter_command_queue_mt_flush(this);
uint32_t allowance_id = WorkerThreadPool::thread_enter_unlock_allowance_zone(&mutex);
while (flush_read_ptr < command_mem.size()) {
uint64_t size = *(uint64_t *)&command_mem[flush_read_ptr];
flush_read_ptr += 8;
@ -383,7 +383,7 @@ class CommandQueueMT {
flush_read_ptr += size;
}
WorkerThreadPool::thread_exit_command_queue_mt_flush();
WorkerThreadPool::thread_exit_unlock_allowance_zone(allowance_id);
command_mem.clear();
flush_read_ptr = 0;