libfilezilla
Public Member Functions | List of all members
condition Class Referencefinal

Waitable condition variable. More...

#include <mutex.hpp>

Public Member Functions

 condition (condition const &)=delete
 
conditionoperator= (condition const &)=delete
 
void wait (scoped_lock &l)
 Wait indefinitely for condition to become signalled. More...
 
bool wait (scoped_lock &l, duration const &timeout)
 Wait until timeout for condition to become signalled. More...
 
void signal (scoped_lock &l)
 Signal condition variable. More...
 
bool signalled (scoped_lock const &) const
 Check if condition is already signalled. More...
 

Detailed Description

Waitable condition variable.

Allows one thread to wait for the condition variable to become signalled by another thread.

Examples
events.cpp.

Member Function Documentation

◆ signal()

void signal ( scoped_lock l)

Signal condition variable.

To avoid race conditions leading to lost signals, you must pass a locked mutex.

Note
Spurious signals are a rare possibility.
The lock must have be on the same mutex that is used for both signalling and for waiting.
Examples
events.cpp.

◆ signalled()

bool signalled ( scoped_lock const &  ) const
inline

Check if condition is already signalled.

To avoid race conditions leading to lost signals, you must pass a locked mutex.

Note
The lock must have be on the same mutex that is used for both signalling and for waiting.

◆ wait() [1/2]

void wait ( scoped_lock l)

Wait indefinitely for condition to become signalled.

Atomically unlocks the mutex and waits for the condition. Atomically consumes the signal and re-locks the mutex.

Note
The lock must have be on the same mutex that is used for both signalling and for waiting.
Examples
events.cpp.

◆ wait() [2/2]

bool wait ( scoped_lock l,
duration const &  timeout 
)

Wait until timeout for condition to become signalled.

Atomically unlocks the mutex and waits for the condition. Atomically consumes the signal and re-locks the mutex.

Returns
true if the condition has been signalled.
false if the condition could not be obtained before the timeout has elapsed.
Note
Spurious signals are a rare possibility.
The lock must have be on the same mutex that is used for both signalling and for waiting.

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