libfoedus-core
FOEDUS Core Library
|
The frequently appearing triplet of condition_varible, "signal" flag for spurious wakeup, and mutex for a one-time single-producer multiple-consumer event synchronization. More...
The frequently appearing triplet of condition_varible, "signal" flag for spurious wakeup, and mutex for a one-time single-producer multiple-consumer event synchronization.
This is basically equivalent to std::promise/future pair with no parameter. The frequent use case is to synchronize with some event for one producer and many waiters. We did use std::promise/future pair for this purpose, but we encountered a bug in libstdc's implementation of std::promise/future. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57440
We are not sure when the fix will be made, nor when the fixed version of gcc/libstdc++ will be prevalent to all environments we support. Very unlikely we can't afford to wait for it. Therefore, we roll it our own.
As this depends on C++11, the name of this file ends with impl. Thus, only private implementation classes directly use this class. If you are okay with C++11, you can use it from client programs, too.
This class is totally header-only.
Definition at line 49 of file rendezvous_impl.hpp.
#include <rendezvous_impl.hpp>
Public Member Functions | |
Rendezvous () | |
Rendezvous (const Rendezvous &other)=delete | |
Rendezvous & | operator= (const Rendezvous &other)=delete |
Rendezvous (Rendezvous &&other)=delete | |
Rendezvous & | operator= (Rendezvous &&other)=delete |
void | wait () |
Block until the event happens. More... | |
template<class REP , class PERIOD > | |
bool | wait_for (const std::chrono::duration< REP, PERIOD > &timeout) |
Block until the event happens or the given period elapses. More... | |
template<class CLOCK , class DURATION > | |
bool | wait_until (const std::chrono::time_point< CLOCK, DURATION > &until) |
Block until the event happens or the given time point arrives. More... | |
void | signal () |
Notify all waiters that the event has happened. More... | |
bool | is_signaled () const |
returns whether this thread has stopped (if the thread hasn't started, false too). More... | |
bool | is_signaled_weak () const |
non-atomic is_signaled(). More... | |
|
inline |
Definition at line 51 of file rendezvous_impl.hpp.
|
delete |
|
delete |
|
inline |
returns whether this thread has stopped (if the thread hasn't started, false too).
Definition at line 115 of file rendezvous_impl.hpp.
Referenced by signal(), wait(), wait_for(), and wait_until().
|
inline |
non-atomic is_signaled().
Definition at line 119 of file rendezvous_impl.hpp.
|
delete |
|
delete |
|
inline |
Notify all waiters that the event has happened.
Equivalent to std::promise<void>::set_value(). There must be only one thread that might call this method, and it should call this only once. Otherwise, the behavior is undefined.
Definition at line 106 of file rendezvous_impl.hpp.
References ASSERT_ND, is_signaled(), and foedus::thread::ConditionVariable::notify_all().
|
inline |
Block until the event happens.
Equivalent to std::future<void>::wait().
Definition at line 64 of file rendezvous_impl.hpp.
References is_signaled(), and foedus::thread::ConditionVariable::wait().
|
inline |
Block until the event happens or the given period elapses.
Equivalent to std::future<void>::wait_for().
Definition at line 78 of file rendezvous_impl.hpp.
References is_signaled(), and foedus::thread::ConditionVariable::wait_for().
|
inline |
Block until the event happens or the given time point arrives.
Equivalent to std::future<void>::wait_until().
Definition at line 92 of file rendezvous_impl.hpp.
References is_signaled(), and foedus::thread::ConditionVariable::wait_until().