CPN
Computational Process Networks
Public Member Functions | Private Attributes | List of all members
Sync::ReentrantCondition Class Reference

Works just like a pthread condition but works with the ReentrantLock. More...

#include <ReentrantLock.h>

+ Collaboration diagram for Sync::ReentrantCondition:

Public Member Functions

 ReentrantCondition ()
 
 ~ReentrantCondition ()
 
void Signal ()
 
void Broadcast ()
 
void Wait (ReentrantLock &lock) const
 

Private Attributes

pthread_cond_t cond
 

Detailed Description

Works just like a pthread condition but works with the ReentrantLock.

Definition at line 123 of file ReentrantLock.h.

Constructor & Destructor Documentation

Sync::ReentrantCondition::ReentrantCondition ( )
inline

Definition at line 125 of file ReentrantLock.h.

References cond, and ENSURE.

125  {
126  ENSURE(!pthread_cond_init(&cond, 0));
127 #ifdef SYNC_PROFILE
128  wait_time = 0;
129 #endif
130  }
#define ENSURE(exp,...)
Sync::ReentrantCondition::~ReentrantCondition ( )
inline

Definition at line 131 of file ReentrantLock.h.

References cond, and ENSURE_ABORT.

131 { ENSURE_ABORT(!pthread_cond_destroy(&cond)); }
#define ENSURE_ABORT(exp,...)

Member Function Documentation

void Sync::ReentrantCondition::Broadcast ( void  )
inline

Definition at line 133 of file ReentrantLock.h.

References cond.

133 { pthread_cond_broadcast(&cond); }
void Sync::ReentrantCondition::Signal ( void  )
inline

Definition at line 132 of file ReentrantLock.h.

References cond.

Referenced by CPN::PseudoNode::CreateReader(), CPN::PseudoNode::CreateWriter(), CPN::Kernel::NodeTerminated(), CPN::PseudoNode::NotifyTerminate(), and CPN::Kernel::SendWakeup().

132 { pthread_cond_signal(&cond); }

+ Here is the caller graph for this function:

void Sync::ReentrantCondition::Wait ( ReentrantLock lock) const
inline

Definition at line 134 of file ReentrantLock.h.

References cond, and Sync::ReentrantLock::lock.

Referenced by CPN::Kernel::EntryPoint(), CPN::PseudoNode::GetReader(), and CPN::PseudoNode::GetWriter().

134  {
135 #ifdef SYNC_PROFILE
136  double time = Internal::getTime();
137  unsigned lock_count = lock.lock_count;
138  lock.lock_count = 0;
139  lock.lock_time += time - lock.lock_last;
140 #endif
141  pthread_cond_wait(&cond, &lock.lock);
142 #ifdef SYNC_PROFILE
143  double end = Internal::getTime();
144  lock.lock_count = lock_count;
145  lock.lock_last = end;
146  wait_time += end - time;
147 #endif
148  }
static PthreadMutex lock
Definition: NodeLoader.cc:36

+ Here is the caller graph for this function:

Member Data Documentation

pthread_cond_t Sync::ReentrantCondition::cond
mutableprivate

Definition at line 156 of file ReentrantLock.h.

Referenced by Broadcast(), ReentrantCondition(), Signal(), Wait(), and ~ReentrantCondition().


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