From bd4edf6e22a3dd60bc68a658de19d18a3b7fd2c3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 12 Aug 2014 18:18:52 +0200 Subject: Core/Threading: Fixed possible race condition with m_timeOutTime and fixed Thread #1: pthread_cond_{signal,broadcast}: dubious: associated lock is not held by any thread in PCQ --- src/server/shared/Threading/ProducerConsumerQueue.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/server/shared/Threading') diff --git a/src/server/shared/Threading/ProducerConsumerQueue.h b/src/server/shared/Threading/ProducerConsumerQueue.h index accb0aebb11..a76b8b0b5c0 100644 --- a/src/server/shared/Threading/ProducerConsumerQueue.h +++ b/src/server/shared/Threading/ProducerConsumerQueue.h @@ -39,10 +39,8 @@ public: void Push(const T& value) { - { - std::lock_guard lock(_queueLock); - _queue.push(std::move(value)); - } + std::lock_guard lock(_queueLock); + _queue.push(std::move(value)); _condition.notify_one(); } @@ -72,10 +70,7 @@ public: { std::unique_lock lock(_queueLock); - while (_queue.empty() && !_shutdown) - { - _condition.wait(lock); - } + _condition.wait(lock, [this]() { return !_queue.empty() || _shutdown; }); if (_queue.empty() || _shutdown) return; -- cgit v1.2.3