mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-09 01:20:04 +01:00
Fix race condition.
This commit is contained in:
parent
48d26e9400
commit
099b05380e
@ -113,16 +113,17 @@ bool ThreadPool::is_working_no_lock() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadPool::has_job(const Ref<ThreadPoolJob> &job) {
|
bool ThreadPool::has_job(const Ref<ThreadPoolJob> &job) {
|
||||||
|
_THREAD_SAFE_LOCK_
|
||||||
|
|
||||||
for (int i = 0; i < _threads.size(); ++i) {
|
for (int i = 0; i < _threads.size(); ++i) {
|
||||||
ThreadPoolContext *context = _threads.get(i);
|
ThreadPoolContext *context = _threads.get(i);
|
||||||
|
|
||||||
if (context->job == job) {
|
if (context->job == job) {
|
||||||
|
_THREAD_SAFE_UNLOCK_
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_THREAD_SAFE_LOCK_
|
|
||||||
|
|
||||||
List<Ref<ThreadPoolJob>>::Element *E = _queue.find(job);
|
List<Ref<ThreadPoolJob>>::Element *E = _queue.find(job);
|
||||||
|
|
||||||
_THREAD_SAFE_UNLOCK_
|
_THREAD_SAFE_UNLOCK_
|
||||||
|
Loading…
Reference in New Issue
Block a user