diff options
Diffstat (limited to 'include/framework/scheduling/LockManager.h')
| -rw-r--r-- | include/framework/scheduling/LockManager.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/framework/scheduling/LockManager.h b/include/framework/scheduling/LockManager.h index 91ed778..fcc79d1 100644 --- a/include/framework/scheduling/LockManager.h +++ b/include/framework/scheduling/LockManager.h @@ -46,7 +46,21 @@ public: return false; } + bool take_buffer_lock() { + bool old = m_buffer_lk.load(); + if (!old) { + return m_buffer_lk.compare_exchange_strong(old, true); + } + + return false; + } + + void release_buffer_lock() { + m_buffer_lk.store(false); + } + private: std::deque<std::atomic<bool>> m_lks; + std::atomic<bool> m_buffer_lk; }; } |