99 pthread_mutexattr_t mAttr;
100 pthread_mutexattr_init (&mAttr);
105 #if defined (PTHREAD_MUTEX_ERRORCHECK_NP)
106 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK_NP);
108 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK);
110 pthread_mutex_init (&
m_mutex, &mAttr);
112 pthread_condattr_t cAttr;
113 pthread_condattr_init (&cAttr);
114 pthread_condattr_setpshared (&cAttr, PTHREAD_PROCESS_PRIVATE);
115 pthread_cond_init (&
m_cond, &cAttr);
121 pthread_mutex_destroy (&
m_mutex);
122 pthread_cond_destroy (&
m_cond);
145 pthread_cond_signal (&
m_cond);
146 pthread_mutex_unlock (&
m_mutex);
155 pthread_cond_broadcast (&
m_cond);
156 pthread_mutex_unlock (&
m_mutex);
170 pthread_mutex_unlock (&
m_mutex);
183 gettimeofday (&tv, NULL);
185 ts.tv_sec += tv.tv_sec;
186 ts.tv_nsec += tv.tv_usec * 1000;
201 pthread_mutex_unlock (&
m_mutex);
205 pthread_mutex_unlock (&
m_mutex);
void Signal(void)
Release one thread if waiting for the condition to be true.
bool GetCondition(void)
Get the value of the underlying condition.
void SetCondition(bool condition)
Set the value of the underlying condition.
void Broadcast(void)
Release all threads waiting for the condition to be true.
SystemConditionPrivate * m_priv
The (system-dependent) implementation.
void Wait(void)
Wait, possibly forever, for the condition to be true.
bool TimedWait(uint64_t ns)
Wait a maximum of ns nanoseconds for the condition to be true.
Implementation of SystemCondition for Unix-like systems.
void Signal(void)
Signal the condition.
void SetCondition(bool condition)
Set the condition.
bool GetCondition(void)
Get the condition value.
~SystemConditionPrivate()
Destructor.
static const uint64_t NS_PER_SEC
Conversion from ns to s.
pthread_cond_t m_cond
The pthread condition variable.
bool TimedWait(uint64_t ns)
Unset the condition, then wait for a limited amount of wall-clock time for another thread to set it w...
void Broadcast(void)
Broadcast the condition.
bool m_condition
The condition state.
pthread_mutex_t m_mutex
Mutex controlling access to the condition.
SystemConditionPrivate()
Constructor.
void Wait(void)
Unset the condition, then wait for another thread to set it with SetCondition.
NS_FATAL_x macro definitions.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SystemCondition declaration.