cortex 0.0.1
Loading...
Searching...
No Matches
cortex::tiny_fiber::ConditionVariable Class Reference

A cooperative condition variable. More...

#include <condition_variable.hpp>

Public Member Functions

 ConditionVariable ()=default
 
 ~ConditionVariable ()
 
 ConditionVariable (const ConditionVariable &)=delete
 
ConditionVariableoperator= (const ConditionVariable &)=delete
 
void Wait (Mutex::Guard &guard)
 Wait until notified.
 
template<typename Predicate >
void Wait (Mutex::Guard &guard, Predicate pred)
 Wait until notified and predicate is true.
 
void NotifyOne ()
 Wake one waiting fiber.
 
void NotifyAll ()
 Wake all waiting fibers.
 

Detailed Description

A cooperative condition variable.

Allows fibers to wait for a condition to be signaled by another fiber.

Constructor & Destructor Documentation

◆ ConditionVariable() [1/2]

cortex::tiny_fiber::ConditionVariable::ConditionVariable ( )
default

◆ ~ConditionVariable()

cortex::tiny_fiber::ConditionVariable::~ConditionVariable ( )

◆ ConditionVariable() [2/2]

cortex::tiny_fiber::ConditionVariable::ConditionVariable ( const ConditionVariable )
delete

Member Function Documentation

◆ NotifyAll()

void cortex::tiny_fiber::ConditionVariable::NotifyAll ( )

Wake all waiting fibers.

◆ NotifyOne()

void cortex::tiny_fiber::ConditionVariable::NotifyOne ( )

Wake one waiting fiber.

◆ operator=()

ConditionVariable & cortex::tiny_fiber::ConditionVariable::operator= ( const ConditionVariable )
delete

◆ Wait() [1/2]

void cortex::tiny_fiber::ConditionVariable::Wait ( Mutex::Guard guard)

Wait until notified.

The mutex must be locked by the current fiber. It will be unlocked while waiting and re-locked before returning.

Parameters
guardThe lock guard holding the mutex.

◆ Wait() [2/2]

template<typename Predicate >
void cortex::tiny_fiber::ConditionVariable::Wait ( Mutex::Guard guard,
Predicate  pred 
)
inline

Wait until notified and predicate is true.

Parameters
guardThe lock guard holding the mutex.
predThe predicate to check.

The documentation for this class was generated from the following file: