Skip to content
Snippets Groups Projects
Commit 0cc57f26 authored by Yohann Bearzi (Kitware)'s avatar Yohann Bearzi (Kitware)
Browse files

vtkThreadedCallbackQueue, fixing race condition

The boolean member `Destroying` needs to be atomic because there is one
location in the code that uses it without mutex
protectionThreadedCallbackQueue, fixing race condition

The boolean member `Destroying` needs to be atomic because there is one
location in the code that uses it without mutex protection
parent 14d1d855
No related branches found
No related tags found
No related merge requests found
......@@ -79,8 +79,8 @@ private:
*/
bool OnHold() const
{
return *this->ThreadIndex < this->Queue->NumberOfThreads && !this->Queue->Destroying &&
this->Queue->InvokerQueue.empty();
return *this->ThreadIndex < this->Queue->NumberOfThreads &&
!this->Queue->Destroying.load(std::memory_order_acquire) && this->Queue->InvokerQueue.empty();
}
/**
......
......@@ -477,7 +477,7 @@ private:
* This atomic boolean is false until destruction. It is then used by the workers
* so they know that they need to terminate when the queue is empty.
*/
bool Destroying = false;
std::atomic_bool Destroying{ false };
/**
* Number of allocated threads. Allocated threads are not necessarily running.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment