libfoedus-core
FOEDUS Core Library
foedus::soc::SharedRendezvous Class Referencefinal

A one-time single-producer multiple-consumer event synchronization in shared memory for multiple processes. More...

Detailed Description

A one-time single-producer multiple-consumer event synchronization in shared memory for multiple processes.

Analogous to SharedMutex. This is a shared version of foedus::thread::Rendezvous.

Definition at line 34 of file shared_rendezvous.hpp.

#include <shared_rendezvous.hpp>

Public Member Functions

 SharedRendezvous ()
 
 ~SharedRendezvous ()
 
 SharedRendezvous (const SharedRendezvous &)=delete
 
SharedRendezvousoperator= (const SharedRendezvous &)=delete
 
void initialize ()
 
void uninitialize ()
 
bool is_initialized () const
 
bool is_signaled () const
 returns whether the even has signaled. More...
 
bool is_signaled_weak () const
 weak version without fence. More...
 
void wait ()
 Block until the event happens. More...
 
bool wait_for (uint64_t timeout_nanosec)
 Block until the event happens or the given period elapses. More...
 
void signal ()
 Notify all waiters that the event has happened. More...
 

Constructor & Destructor Documentation

foedus::soc::SharedRendezvous::SharedRendezvous ( )
inline

Definition at line 36 of file shared_rendezvous.hpp.

References initialize().

36 : signaled_(false), initialized_(false), cond_() { initialize(); }

Here is the call graph for this function:

foedus::soc::SharedRendezvous::~SharedRendezvous ( )
inline

Definition at line 37 of file shared_rendezvous.hpp.

References uninitialize().

Here is the call graph for this function:

foedus::soc::SharedRendezvous::SharedRendezvous ( const SharedRendezvous )
delete

Member Function Documentation

void foedus::soc::SharedRendezvous::initialize ( )

Definition at line 27 of file shared_rendezvous.cpp.

References foedus::soc::SharedPolling::initialize(), and uninitialize().

Referenced by SharedRendezvous().

27  {
28  uninitialize();
29  signaled_ = false;
30  initialized_ = true;
31  cond_.initialize();
32 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::soc::SharedRendezvous::is_initialized ( ) const
inline

Definition at line 45 of file shared_rendezvous.hpp.

Referenced by uninitialize().

45 { return initialized_; }

Here is the caller graph for this function:

bool foedus::soc::SharedRendezvous::is_signaled ( ) const
inline

returns whether the even has signaled.

Definition at line 48 of file shared_rendezvous.hpp.

References foedus::assorted::memory_fence_acquire().

Referenced by wait(), and wait_for().

48  {
50  return signaled_;
51  }
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::soc::SharedRendezvous::is_signaled_weak ( ) const
inline

weak version without fence.

Definition at line 53 of file shared_rendezvous.hpp.

Referenced by wait(), and wait_for().

53 { return signaled_; }

Here is the caller graph for this function:

SharedRendezvous& foedus::soc::SharedRendezvous::operator= ( const SharedRendezvous )
delete
void foedus::soc::SharedRendezvous::signal ( )

Notify all waiters that the event has happened.

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 67 of file shared_rendezvous.cpp.

References foedus::soc::SharedPolling::signal().

67  {
68  signaled_ = true;
69  cond_.signal();
70 }
void signal()
Signal it to let waiters exit.

Here is the call graph for this function:

void foedus::soc::SharedRendezvous::uninitialize ( )

Definition at line 34 of file shared_rendezvous.cpp.

References is_initialized().

Referenced by initialize(), and ~SharedRendezvous().

34  {
35  if (!is_initialized()) {
36  return;
37  }
38 }

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::soc::SharedRendezvous::wait ( )

Block until the event happens.

Definition at line 40 of file shared_rendezvous.cpp.

References foedus::soc::SharedPolling::acquire_ticket(), ASSERT_ND, is_signaled(), is_signaled_weak(), and foedus::soc::SharedPolling::wait().

40  {
41  if (is_signaled_weak()) { // just an optimization.
42  return;
43  }
44 
45  uint64_t demand = cond_.acquire_ticket();
46  if (is_signaled()) {
47  return;
48  }
49  cond_.wait(demand);
51 }
bool is_signaled() const
returns whether the even has signaled.
void wait(uint64_t demanded_ticket, uint64_t polling_spins=kDefaultPollingSpins, uint64_t max_interval_us=kDefaultPollingMaxIntervalUs) const
Unconditionally wait for signal.
uint64_t acquire_ticket() const
Gives the ticket to.
bool is_signaled_weak() const
weak version without fence.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

bool foedus::soc::SharedRendezvous::wait_for ( uint64_t  timeout_nanosec)

Block until the event happens or the given period elapses.

Returns
whether the event happened by now.

Definition at line 53 of file shared_rendezvous.cpp.

References foedus::soc::SharedPolling::acquire_ticket(), ASSERT_ND, is_signaled(), is_signaled_weak(), and foedus::soc::SharedPolling::timedwait().

53  {
54  if (is_signaled_weak()) { // just an optimization.
55  return true;
56  }
57 
58  uint64_t demand = cond_.acquire_ticket();
59  if (is_signaled()) {
60  return true;
61  }
62  bool received = cond_.timedwait(demand, timeout_nanosec / 1000);
63  ASSERT_ND(!received || is_signaled());
64  return is_signaled();
65 }
bool is_signaled() const
returns whether the even has signaled.
uint64_t acquire_ticket() const
Gives the ticket to.
bool is_signaled_weak() const
weak version without fence.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
bool timedwait(uint64_t demanded_ticket, uint64_t timeout_microsec, uint64_t polling_spins=kDefaultPollingSpins, uint64_t max_interval_us=kDefaultPollingMaxIntervalUs) const
Wait for signal up to the given timeout.

Here is the call graph for this function:


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