cortex 0.0.1
Loading...
Searching...
No Matches
condition_variable.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <deque>
7
14
22public:
23 ConditionVariable() = default;
25
28
37 void Wait(Mutex::Guard& guard);
38
45 template <typename Predicate>
46 void Wait(Mutex::Guard& guard, Predicate pred) {
47 while (!pred()) {
48 Wait(guard);
49 }
50 }
51
55 void NotifyOne();
56
60 void NotifyAll();
61
62private:
63 std::deque<detail::Fiber*> waiters_;
64};
65
66} // namespace cortex::tiny_fiber
A cooperative condition variable.
Definition condition_variable.hpp:21
void NotifyAll()
Wake all waiting fibers.
void Wait(Mutex::Guard &guard, Predicate pred)
Wait until notified and predicate is true.
Definition condition_variable.hpp:46
void Wait(Mutex::Guard &guard)
Wait until notified.
ConditionVariable & operator=(const ConditionVariable &)=delete
void NotifyOne()
Wake one waiting fiber.
ConditionVariable(const ConditionVariable &)=delete
RAII lock guard for Mutex.
Definition mutex.hpp:27
Cooperative mutex for tiny_fiber.
Cooperative multitasking primitives built on cortex::Coroutine.
Definition condition_variable.hpp:13