Commit 04e14857 by Nicolas Capens Committed by Nicolas Capens

Make round-robin task enqueue index thread safe

Addresses TSAN error in Chromium viz_unittests and cc_unittests. Bug: b/139010488 Change-Id: I1a53487c4787170c38898cca47bf76145ebdf6bd Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35608 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent cde4dd96
...@@ -99,6 +99,7 @@ void Scheduler::unbind() ...@@ -99,6 +99,7 @@ void Scheduler::unbind()
} }
Scheduler::Scheduler() Scheduler::Scheduler()
: nextEnqueueIndex(0)
{ {
for (size_t i = 0; i < spinningWorkers.size(); i++) for (size_t i = 0; i < spinningWorkers.size(); i++)
{ {
......
...@@ -294,7 +294,7 @@ private: ...@@ -294,7 +294,7 @@ private:
// TODO: Make this lot thread-safe so setWorkerThreadCount() can be called // TODO: Make this lot thread-safe so setWorkerThreadCount() can be called
// during execution of tasks. // during execution of tasks.
unsigned int nextEnqueueIndex = 0; std::atomic<unsigned int> nextEnqueueIndex;
unsigned int numWorkerThreads = 0; unsigned int numWorkerThreads = 0;
std::array<Worker*, MaxWorkerThreads> workerThreads; std::array<Worker*, MaxWorkerThreads> workerThreads;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment