diff --git a/Parallel/Core/vtkThreadedCallbackQueue.cxx b/Parallel/Core/vtkThreadedCallbackQueue.cxx index 6dfaa11511911191c27472cefeecac78127517bc..b830f9bba7101ea6ca7519804c2590774b08f9ad 100644 --- a/Parallel/Core/vtkThreadedCallbackQueue.cxx +++ b/Parallel/Core/vtkThreadedCallbackQueue.cxx @@ -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(); } /** diff --git a/Parallel/Core/vtkThreadedCallbackQueue.h b/Parallel/Core/vtkThreadedCallbackQueue.h index 7fa4fe8d54de88fed77a5d63229962bc38402299..e26a1b5f9f6dfc15cc9f97d5c60512c46e9c9312 100644 --- a/Parallel/Core/vtkThreadedCallbackQueue.h +++ b/Parallel/Core/vtkThreadedCallbackQueue.h @@ -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.