summaryrefslogtreecommitdiff
path: root/src/KingSystem/Utils/Thread/TaskQueueLock.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-09-10 22:11:27 +0200
committerLéo Lam <leo@leolam.fr>2020-09-15 17:54:16 +0200
commit8b7369dffb1e816b2f27ab0133d2bac218383a45 (patch)
treec5d6a577ec9102e65a6e08272432dfa862670a60 /src/KingSystem/Utils/Thread/TaskQueueLock.cpp
parentc5ef0a1fd3629a27dc2fc7de7a46347c6cb3518e (diff)
ksys: Add Task utilities
Diffstat (limited to 'src/KingSystem/Utils/Thread/TaskQueueLock.cpp')
-rw-r--r--src/KingSystem/Utils/Thread/TaskQueueLock.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/KingSystem/Utils/Thread/TaskQueueLock.cpp b/src/KingSystem/Utils/Thread/TaskQueueLock.cpp
new file mode 100644
index 00000000..be7b1c5e
--- /dev/null
+++ b/src/KingSystem/Utils/Thread/TaskQueueLock.cpp
@@ -0,0 +1,26 @@
+#include "KingSystem/Utils/Thread/TaskQueueLock.h"
+#include "KingSystem/Utils/Thread/TaskQueueBase.h"
+
+namespace ksys::util {
+
+TaskQueueLock::TaskQueueLock() = default;
+
+TaskQueueLock::~TaskQueueLock() {
+ unlock();
+}
+
+void TaskQueueLock::lock(TaskQueueBase* queue) {
+ if (!mQueue) {
+ mQueue = queue;
+ mQueue->lock();
+ }
+}
+
+void TaskQueueLock::unlock() {
+ if (mQueue) {
+ mQueue->unlock();
+ mQueue = nullptr;
+ }
+}
+
+} // namespace ksys::util