cwidget  0.5.17
Public Member Functions | List of all members
cwidget::threads::condition Class Reference

A abstraction over conditions. More...

#include <threads.h>

Public Member Functions

void wake_one ()
 
void wake_all ()
 
template<typename Lock >
void wait (const Lock &l)
 Wait with the given guard (should be a lock type that is a friend of this condition object). More...
 
template<typename Lock , typename Pred >
void wait (const Lock &l, Pred p)
 Wait until the given predicate returns true. More...
 
template<typename Lock >
bool timed_wait (const Lock &l, const timespec &until)
 Wait until either the condition is signalled or until the given time. More...
 
template<typename Lock , typename Pred >
bool timed_wait (const Lock &l, const timespec &until, const Pred &p)
 Wait either until the condition is signalled while the given predicate is true or until the given time. More...
 

Detailed Description

A abstraction over conditions.

When a condition variable is destroyed, any threads that are still blocked on it are woken up.

Member Function Documentation

◆ timed_wait() [1/2]

template<typename Lock >
bool cwidget::threads::condition::timed_wait ( const Lock &  l,
const timespec &  until 
)
inline

Wait until either the condition is signalled or until the given time.

This is a cancellation point. If the thread is cancelled while waiting on the condition, the mutex will be unlocked. This does not apply to the predicate; it is responsible for cleaning up the mutex itself if the thread is cancelled while it is running.

Parameters
lthe guard of the condition
untilthe time at which the wait should terminate
Returns
true if the condition occurred or false if time ran out.

Referenced by cwidget::toplevel::post_event(), and cwidget::threads::event_queue< T >::timed_get().

◆ timed_wait() [2/2]

template<typename Lock , typename Pred >
bool cwidget::threads::condition::timed_wait ( const Lock &  l,
const timespec &  until,
const Pred &  p 
)
inline

Wait either until the condition is signalled while the given predicate is true or until the given time.

This is a cancellation point. If the thread is cancelled while waiting on the condition mutex will be unlocked. If the thread is cancelled while invoking the predicate, no guarantees are made by this routine; if the predicate invokes a cancellation point, it is responsible for pushing a cleanup handler.

◆ wait() [1/2]

template<typename Lock >
void cwidget::threads::condition::wait ( const Lock &  l)
inline

Wait with the given guard (should be a lock type that is a friend of this condition object).

This is a cancellation point. If the thread is cancelled while waiting on the condition, the mutex will be unlocked.

Referenced by cwidget::threads::event_queue< T >::get(), and cwidget::toplevel::post_event().

◆ wait() [2/2]

template<typename Lock , typename Pred >
void cwidget::threads::condition::wait ( const Lock &  l,
Pred  p 
)
inline

Wait until the given predicate returns true.

This is a cancellation point. If the thread is cancelled while waiting on the condition, the mutex will be unlocked. This does not apply to the predicate; it is responsible for cleaning up the mutex itself if the thread is cancelled while it is running.


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