Skip to content

Commit be79161

Browse files
authored
Merge pull request #15214 from unknownbrackets/threads-atomic
ThreadManager: Check for exchange failure
2 parents 5907897 + 7c7340e commit be79161

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Common/Thread/ThreadManager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) {
264264

265265
// Try first atomically, as highest priority.
266266
Task *expected = nullptr;
267-
thread->private_single.compare_exchange_weak(expected, task);
267+
bool queued = thread->private_single.compare_exchange_weak(expected, task);
268268
// Whether we got that or will have to wait, increase the queue counter.
269269
thread->queue_size++;
270270

271-
if (expected == nullptr) {
271+
if (queued) {
272272
std::unique_lock<std::mutex> lock(thread->mutex);
273273
thread->cond.notify_one();
274274
} else {

0 commit comments

Comments
 (0)