diff options
| author | Léo Lam <leo@leolam.fr> | 2020-09-10 22:11:27 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2020-09-15 17:54:16 +0200 |
| commit | 8b7369dffb1e816b2f27ab0133d2bac218383a45 (patch) | |
| tree | c5d6a577ec9102e65a6e08272432dfa862670a60 /src/KingSystem/Utils/Thread/TaskQueueLock.cpp | |
| parent | c5ef0a1fd3629a27dc2fc7de7a46347c6cb3518e (diff) | |
ksys: Add Task utilities
Diffstat (limited to 'src/KingSystem/Utils/Thread/TaskQueueLock.cpp')
| -rw-r--r-- | src/KingSystem/Utils/Thread/TaskQueueLock.cpp | 26 |
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 |
