Fix race condition.

This commit is contained in:
Relintai 2022-09-17 22:35:42 +02:00
parent 48d26e9400
commit 099b05380e

View File

@ -113,16 +113,17 @@ bool ThreadPool::is_working_no_lock() const {
}
bool ThreadPool::has_job(const Ref<ThreadPoolJob> &job) {
_THREAD_SAFE_LOCK_
for (int i = 0; i < _threads.size(); ++i) {
ThreadPoolContext *context = _threads.get(i);
if (context->job == job) {
_THREAD_SAFE_UNLOCK_
return true;
}
}
_THREAD_SAFE_LOCK_
List<Ref<ThreadPoolJob>>::Element *E = _queue.find(job);
_THREAD_SAFE_UNLOCK_