CoopSync for TBB 0.1.0
Cooperative synchronization primitives for TBB resumable tasks
Loading...
Searching...
No Matches
coopsync_tbb::condition_variable Class Reference

Condition variable used to synchronize tasks. The tasks can be suspended on this condition variable and then later notify to resume if given condition is met. More...

#include <coopsync_tbb/condition_variable.hpp>

Public Member Functions

 condition_variable ()=default
 Constructs a new condition variable.
 condition_variable (const condition_variable &)=delete
 The condition_variable is not copy-constructible.
condition_variable & operator= (const condition_variable &)=delete
 The condition_variable is not copy-assignable.
 condition_variable (condition_variable &&)=delete
 THe condition_variable is not move-constructible.
condition_variable & operator= (condition_variable &&)=delete
 The condition_variable is not move-assignable.
 ~condition_variable ()
 Destroys the condition variable.
void notify_one ()
 Resumes one task suspended waiting on this condition variable, if there is any.
void notify_all ()
 Resumes all tasks suspended waiting on this condition variable.
template<typename Lock>
void wait (Lock &lock)
 Suspends the calling task until it is notified.
template<typename Lock, typename Pred>
void wait (Lock &lock, Pred pred)
 Suspends the calling task until pred() becomes true.

Detailed Description

Condition variable used to synchronize tasks. The tasks can be suspended on this condition variable and then later notify to resume if given condition is met.

Constructor & Destructor Documentation

◆ ~condition_variable()

coopsync_tbb::condition_variable::~condition_variable ( )

Destroys the condition variable.

Note
The destructor must not be called while there are still tasks waiting on the condition variable. The destructor does not notify or resume any waiting tasks.

Member Function Documentation

◆ wait() [1/2]

template<typename Lock>
void coopsync_tbb::condition_variable::wait ( Lock & lock)
inline

Suspends the calling task until it is notified.

Template Parameters
LockA lock type providing lock() and unlock().
Parameters
lockThe lock to be released while waiting and reacquired after resumption. The lock must be in an locked state before calling this function.

◆ wait() [2/2]

template<typename Lock, typename Pred>
void coopsync_tbb::condition_variable::wait ( Lock & lock,
Pred pred )
inline

Suspends the calling task until pred() becomes true.

Template Parameters
LockA lock type providing lock() and unlock().
PredCallable returning bool. Must be invocable without arguments.
Parameters
lockThe lock to be released while waiting and reacquired after resumption. The lock must be in an locked state before calling this function.
predThe predicate to be evaluated after each resumption, if it returns false the task is suspended again.
Exceptions
anyexception thrown by pred().

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