summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dotrunner.cpp17
-rw-r--r--src/dotrunner.h7
2 files changed, 11 insertions, 13 deletions
diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp
index 208250a..a42c242 100644
--- a/src/dotrunner.cpp
+++ b/src/dotrunner.cpp
@@ -256,19 +256,18 @@ error:
void DotRunnerQueue::enqueue(DotRunner *runner)
{
- QMutexLocker locker(&m_mutex);
+ std::lock_guard<std::mutex> locker(m_mutex);
m_queue.push(runner);
- m_bufferNotEmpty.wakeAll();
+ m_bufferNotEmpty.notify_all();
}
DotRunner *DotRunnerQueue::dequeue()
{
- QMutexLocker locker(&m_mutex);
- while (m_queue.empty())
- {
- // wait until something is added to the queue
- m_bufferNotEmpty.wait(&m_mutex);
- }
+ std::unique_lock<std::mutex> locker(m_mutex);
+
+ // wait until something is added to the queue
+ m_bufferNotEmpty.wait(locker, [this]() {return !m_queue.empty(); });
+
DotRunner *result = m_queue.front();
m_queue.pop();
return result;
@@ -276,7 +275,7 @@ DotRunner *DotRunnerQueue::dequeue()
uint DotRunnerQueue::count() const
{
- QMutexLocker locker(&m_mutex);
+ std::lock_guard<std::mutex> locker(m_mutex);
return m_queue.size();
}
diff --git a/src/dotrunner.h b/src/dotrunner.h
index 48b3dcb..2fa0b61 100644
--- a/src/dotrunner.h
+++ b/src/dotrunner.h
@@ -18,10 +18,9 @@
#include "qcstring.h"
#include "qlist.h"
-#include "qwaitcondition.h"
#include "qthread.h"
#include <queue>
-#include "qmutex.h"
+#include <mutex>
/** Minimal constant string class that is thread safe, once initialized. */
class DotConstString
@@ -114,9 +113,9 @@ class DotRunnerQueue
DotRunner *dequeue();
uint count() const;
private:
- QWaitCondition m_bufferNotEmpty;
+ std::condition_variable m_bufferNotEmpty;
std::queue<DotRunner *> m_queue;
- mutable QMutex m_mutex;
+ mutable std::mutex m_mutex;
};
/** Worker thread to execute a dot run */