18 #ifndef SEMAPHORE_HPP_ 19 #define SEMAPHORE_HPP_ 23 #include <condition_variable> 44 template<
class Rep,
class Period>
45 bool wait_for(
const std::chrono::duration<Rep, Period> &rel_time);
46 template<
class Clock,
class Duration>
48 const std::chrono::time_point<Clock, Duration> &timeout_time);
55 std::condition_variable cv_;
65 template<
class Rep,
class Period>
68 std::unique_lock<std::mutex> lock(mutex_);
69 bool result = cv_.wait_for(lock, rel_time, [
this]()
89 template<
class Clock,
class Duration>
91 const std::chrono::time_point<Clock, Duration> &timeout_time)
93 std::unique_lock<std::mutex> lock(mutex_);
94 bool result = cv_.wait_until(lock, timeout_time, [
this]()
108 #endif // SEMAPHORE_HPP_
bool wait_until(const std::chrono::time_point< Clock, Duration > &timeout_time)
semaphore(const semaphore &other)=delete
semaphore & operator=(const semaphore &other)=delete
bool wait_for(const std::chrono::duration< Rep, Period > &rel_time)