12 #ifndef RTCTK_DATATASK_SEMAPHORE_HPP
13 #define RTCTK_DATATASK_SEMAPHORE_HPP
16 #include <condition_variable>
32 std::unique_lock<std::mutex> lock(m_mtx);
39 std::unique_lock<std::mutex> lock(m_mtx);
40 m_cv.wait(lock, [&]{
return m_count != 0;});
44 template <
class Rep,
class Period>
45 inline void Wait(std::chrono::duration<Rep, Period> timeout) {
46 std::unique_lock<std::mutex> lock(m_mtx);
47 auto ret = m_cv.wait_for(lock, timeout, [&]{
return m_count != 0;});
49 throw(std::runtime_error(
"Semaphor.Wait() timed out"));
55 std::unique_lock<std::mutex> lock(m_mtx);
65 std::unique_lock<std::mutex> lock(m_mtx);
72 std::condition_variable m_cv;