Seastar
High performance C++ framework for concurrent servers
|
Conditional variable.
This is a standard computer science condition variable sans locking, since in seastar access to variables is atomic anyway, adapted for futures. You can wait for variable to be notified.
To support exceptional conditions, a broken() method is provided, which causes all current waiters to stop waiting, with an exceptional future returned. This allows causing all fibers that are blocked on a condition variable to continue. This issimilar to POSIX's pthread_cancel()
, with wait() acting as a cancellation point.
#include <seastar/core/condition-variable.hh>
Public Member Functions | |
condition_variable () noexcept=default | |
condition_variable (condition_variable &&rhs) noexcept=default | |
future | wait () noexcept |
template<typename Clock = typename timer<>::clock, typename Duration = typename Clock::duration> | |
future | wait (std::chrono::time_point< Clock, Duration > timeout) noexcept |
template<typename Rep , typename Period > | |
future | wait (std::chrono::duration< Rep, Period > timeout) noexcept |
template<typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
future | wait (Pred &&pred) noexcept |
template<typename Clock = typename timer<>::clock, typename Duration = typename Clock::duration, typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
future | wait (std::chrono::time_point< Clock, Duration > timeout, Pred &&pred) noexcept |
template<typename Rep , typename Period , typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
future | wait (std::chrono::duration< Rep, Period > timeout, Pred &&pred) noexcept |
awaiter | when () noexcept |
template<typename Clock = typename timer<>::clock, typename Duration = typename Clock::duration> | |
timeout_awaiter< Clock, Duration > | when (std::chrono::time_point< Clock, Duration > timeout) noexcept |
template<typename Rep , typename Period > | |
auto | when (std::chrono::duration< Rep, Period > timeout) noexcept |
template<typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
auto | when (Pred &&pred) noexcept |
template<typename Clock = typename timer<>::clock, typename Duration = typename Clock::duration, typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
auto | when (std::chrono::time_point< Clock, Duration > timeout, Pred &&pred) noexcept |
template<typename Rep , typename Period , typename Pred > requires std::is_invocable_r_v<bool, Pred> | |
auto | when (std::chrono::duration< Rep, Period > timeout, Pred &&pred) noexcept |
bool | has_waiters () const noexcept |
void | signal () noexcept |
Notify variable and wake up a waiter if there is one. | |
void | broadcast () noexcept |
Notify variable and wake up all waiter. | |
void | broken () noexcept |
void | broken (std::exception_ptr) noexcept |
|
defaultnoexcept |
Constructs a condition_variable object. Initialzie the semaphore with a default value of 0 to enusre the first call to wait() before signal() won't be waken up immediately.
|
noexcept |
Signal to waiters that an error occurred. wait() will see an exceptional future<> containing the provided exception parameter. The future is made available immediately.
|
inlinenoexcept |
Whether or not the condition variable currently has pending waiter(s) The returned answer is valid until next continuation/fiber switch.
|
inlinenoexcept |
Waits until condition variable is signaled, may wake up without condition been met
|
inlinenoexcept |
|
inlinenoexcept |
Waits until condition variable is signaled or timeout is reached
timeout | duration after which wait will exit with a timeout |
|
inlinenoexcept |
Waits until condition variable is notified and pred() == true or timeout is reached, otherwise wait again.
timeout | duration after which wait will exit with a timeout |
pred | predicate that checks that awaited condition is true |
|
inlinenoexcept |
Waits until condition variable is signaled or timeout is reached
timeout | time point at which wait will exit with a timeout |
|
inlinenoexcept |
Waits until condition variable is notified and pred() == true or timeout is reached, otherwise wait again.
timeout | time point at which wait will exit with a timeout |
pred | predicate that checks that awaited condition is true |
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is signaled, may wake up without condition been met
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is notified and pred() == true, otherwise wait again.
pred | predicate that checks that awaited condition is true |
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is signaled or timeout is reached
timeout | duration after which wait will exit with a timeout |
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is notified and pred() == true or timeout is reached, otherwise wait again.
timeout | duration after which wait will exit with a timeout |
pred | predicate that checks that awaited condition is true |
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is signaled or timeout is reached
timeout | time point at which wait will exit with a timeout |
|
inlinenoexcept |
Coroutine/co_await only waiter. Waits until condition variable is notified and pred() == true or timeout is reached, otherwise wait again.
timeout | time point at which wait will exit with a timeout |
pred | predicate that checks that awaited condition is true |