Nana C++ Library  

An open-source C++ framework project
The Programmer's Guide 
nana::threads::condition_variable

Description

The class condition_variable provides synchronization primitives used to block a thread until notified by some other thread that some condition is met or until a system time is reached.

Model of

None

Public base classes

None

Typedefs

native_handle_type  The type of native handle.

Members

condition_variable() The construction.
~condition_variable() The destruction.
void notify_one() Unblocks one of threads that are blocked waiting for the condition variable.
void notify_all() Unblocks all threads that are blocked waiting for the condition variable,
void wait(unique_lock<mutex> & u) Unlocks the u and waits for a notification, and after the wait, locks u.
template<typename Predicate>
void wait(unique_lock<mutex> & u, Predicate pred)
while(!pred()) wait(u);
bool wait_for(unique_lock<mutex> & u, std::size_t milliseconds) Waits for a notification. it returns true, the time is out.
template<typename Predicate>
bool wait_for(unique_lock<mutex>& u, std::size_t milliseconds, Predicate pred)
while(!pred())
    if(wait_for(u, milliseconds))
        return pred();
return true;
native_handle_type native_handle() Returns the native handle.

File

nana/threads/condition_varialbe.hpp

Notes

None

See also

None.


Move to The Nana Programmer's Guide Main Page