97 pthread_mutexattr_t mAttr;
98 pthread_mutexattr_init (&mAttr);
103 #if defined (PTHREAD_MUTEX_ERRORCHECK_NP)
104 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK_NP);
106 pthread_mutexattr_settype (&mAttr, PTHREAD_MUTEX_ERRORCHECK);
108 pthread_mutex_init (&
m_mutex, &mAttr);
110 pthread_condattr_t cAttr;
111 pthread_condattr_init (&cAttr);
112 pthread_condattr_setpshared (&cAttr, PTHREAD_PROCESS_PRIVATE);
113 pthread_cond_init (&
m_cond, &cAttr);
119 pthread_mutex_destroy (&
m_mutex);
120 pthread_cond_destroy (&
m_cond);
143 pthread_cond_signal (&
m_cond);
144 pthread_mutex_unlock (&
m_mutex);
153 pthread_cond_broadcast (&
m_cond);
154 pthread_mutex_unlock (&
m_mutex);
168 pthread_mutex_unlock (&
m_mutex);
181 gettimeofday (&tv, NULL);
183 ts.tv_sec += tv.tv_sec;
184 ts.tv_nsec += tv.tv_usec * 1000;
199 pthread_mutex_unlock (&
m_mutex);
203 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.
System-independent thread conditional wait.
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.
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.