98 pthread_mutexattr_t mAttr;
99 pthread_mutexattr_init (&mAttr);
104 #if defined (PTHREAD_MUTEX_ERRORCHECK_NP) 105 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK_NP);
107 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK);
109 pthread_mutex_init (&
m_mutex, &mAttr);
111 pthread_condattr_t cAttr;
112 pthread_condattr_init (&cAttr);
113 pthread_condattr_setpshared (&cAttr, PTHREAD_PROCESS_PRIVATE);
114 pthread_cond_init (&
m_cond, &cAttr);
120 pthread_mutex_destroy (&
m_mutex);
121 pthread_cond_destroy (&
m_cond);
144 pthread_cond_signal (&
m_cond);
145 pthread_mutex_unlock (&
m_mutex);
154 pthread_cond_broadcast (&
m_cond);
155 pthread_mutex_unlock (&
m_mutex);
169 pthread_mutex_unlock (&
m_mutex);
182 gettimeofday (&tv, NULL);
184 ts.tv_sec += tv.tv_sec;
185 ts.tv_nsec += tv.tv_usec * 1000;
200 pthread_mutex_unlock (&
m_mutex);
204 pthread_mutex_unlock (&
m_mutex);
NS_FATAL_x macro definitions.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void Signal(void)
Signal the condition.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
ns3::SystemCondition declaration.
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...
pthread_cond_t m_cond
The pthread condition variable.
void Signal(void)
Release one thread if waiting for the condition to be true.
void Broadcast(void)
Broadcast the condition.
void Broadcast(void)
Release all threads waiting for the condition to be true.
void SetCondition(bool condition)
Set the condition.
void Wait(void)
Wait, possibly forever, for the condition to be true.
void SetCondition(bool condition)
Set the value of the underlying condition.
bool GetCondition(void)
Get the value of the underlying condition.
void Wait(void)
Unset the condition, then wait for another thread to set it with SetCondition.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool TimedWait(uint64_t ns)
Wait a maximum of ns nanoseconds for the condition to be true.
bool m_condition
The condition state.
SystemConditionPrivate()
Constructor.
~SystemConditionPrivate()
Destructor.
Implementation of SystemCondition for Unix-like systems.
SystemConditionPrivate * m_priv
The (system-dependent) implementation.
static const uint64_t NS_PER_SEC
Conversion from ns to s.
pthread_mutex_t m_mutex
Mutex controlling access to the condition.
bool GetCondition(void)
Get the condition value.