34 #ifndef _UCOMMON_CONDITION_H_ 35 #define _UCOMMON_CONDITION_H_ 37 #ifndef _UCOMMON_CPR_H_ 41 #ifndef _UCOMMON_ACCESS_H_ 45 #ifndef _UCOMMON_TIMERS_H_ 49 #ifndef _UCOMMON_MEMORY_H_ 70 #if defined(_MSTHREADS_) 71 mutable CRITICAL_SECTION mutex;
88 inline void lock(
void) {
89 EnterCriticalSection(&mutex);
92 inline void unlock(
void) {
93 LeaveCriticalSection(&mutex);
101 pthread_mutex_lock(&mutex);
108 pthread_mutex_unlock(&mutex);
116 CRITICAL_SECTION *mutex;
124 mutex = &
object->mutex;
126 EnterCriticalSection(mutex);
128 pthread_mutex_lock(mutex);
134 LeaveCriticalSection(mutex);
136 pthread_mutex_unlock(mutex);
154 friend class ConditionList;
156 #if defined(_MSTHREADS_) 157 mutable CONDITION_VARIABLE cond;
186 bool wait(
struct timespec *
timeout);
191 void broadcast(
void);
198 pthread_cond_wait(&cond, &shared->
mutex);
205 pthread_cond_signal(&cond);
212 pthread_cond_broadcast(&cond);
236 #if defined(_MSTHREADS_) 237 mutable CONDITION_VARIABLE cond;
267 bool wait(
struct timespec *
timeout);
272 void broadcast(
void);
279 pthread_cond_wait(&cond, &mutex);
286 pthread_cond_signal(&cond);
293 pthread_cond_broadcast(&cond);
310 #if !defined(_MSTHREADS_) && !defined(__PTH__) 343 #if defined _MSTHREADS_ 344 CONDITION_VARIABLE bcast;
373 bool waitSignal(
struct timespec *
timeout);
380 bool waitBroadcast(
struct timespec *
timeout);
394 inline void lock(
void) {
395 EnterCriticalSection(&mutex);
398 inline void unlock(
void) {
399 LeaveCriticalSection(&mutex);
402 void waitSignal(
void);
404 void waitBroadcast(
void);
406 inline void signal(
void) {
410 inline void broadcast(
void) {
419 pthread_mutex_lock(&mutex);
426 pthread_mutex_unlock(&mutex);
433 pthread_cond_wait(&cond, &mutex);
440 pthread_cond_wait(&bcast, &mutex);
448 pthread_cond_signal(&cond);
455 pthread_cond_broadcast(&bcast);
495 void limit_sharing(
unsigned max);
568 virtual void exclusive(
void);
573 virtual void share(
void);
613 void set(
unsigned count);
629 unsigned operator++(
void);
631 unsigned operator--(
void);
679 Semaphore(
unsigned count,
unsigned avail);
700 void set(
unsigned count);