mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
ThreadManager: Check for exchange failure.
Even if expected stays null, since it's weak assume it can fail.
This commit is contained in:
parent
5907897c36
commit
7c7340e338
@ -264,11 +264,11 @@ void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) {
|
||||
|
||||
// Try first atomically, as highest priority.
|
||||
Task *expected = nullptr;
|
||||
thread->private_single.compare_exchange_weak(expected, task);
|
||||
bool queued = thread->private_single.compare_exchange_weak(expected, task);
|
||||
// Whether we got that or will have to wait, increase the queue counter.
|
||||
thread->queue_size++;
|
||||
|
||||
if (expected == nullptr) {
|
||||
if (queued) {
|
||||
std::unique_lock<std::mutex> lock(thread->mutex);
|
||||
thread->cond.notify_one();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user