aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Threading/ProducerConsumerQueue.h
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-08-12 18:18:52 +0200
committerShauren <shauren.trinity@gmail.com>2014-08-12 18:18:52 +0200
commitbd4edf6e22a3dd60bc68a658de19d18a3b7fd2c3 (patch)
tree6e3a4342f1f127b9c5e82749aa77b84ec6bfe43a /src/server/shared/Threading/ProducerConsumerQueue.h
parent9f7075215d0efdb357abf13ed10a10122fe70039 (diff)
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
Diffstat (limited to 'src/server/shared/Threading/ProducerConsumerQueue.h')
-rw-r--r--src/server/shared/Threading/ProducerConsumerQueue.h11
1 files changed, 3 insertions, 8 deletions
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<std::mutex> lock(_queueLock);
- _queue.push(std::move(value));
- }
+ std::lock_guard<std::mutex> lock(_queueLock);
+ _queue.push(std::move(value));
_condition.notify_one();
}
@@ -72,10 +70,7 @@ public:
{
std::unique_lock<std::mutex> lock(_queueLock);
- while (_queue.empty() && !_shutdown)
- {
- _condition.wait(lock);
- }
+ _condition.wait(lock, [this]() { return !_queue.empty() || _shutdown; });
if (_queue.empty() || _shutdown)
return;