libUTL++
ConditionVar.h
1 #pragma once
2 
4 
5 #include <libutl/host_thread.h>
6 #include <libutl/Mutex.h>
7 
9 
10 UTL_NS_BEGIN;
11 
13 
28 
30 class ConditionVar : public Object, public NamedObjectMI
31 {
34 
35 public:
37  void broadcast();
38 
40  void signal();
41 
46  void wait();
47 
49  void lockMutex();
50 
52  void unlockMutex();
53 
54 private:
55  void init();
56  void deInit();
57 
58 private:
59 #if UTL_HOST_OS == UTL_OS_MINGW
60  void* _mutex;
61  int _numWaiters;
62  struct _CRITICAL_SECTION* _numWaitersLock;
63  void* _sem;
64  void* _waitersDone;
65  uint_t _wasBroadcast;
66 #else
67  Mutex _mutex;
68  pthread_cond_t _cond;
69 #endif
70 };
71 
73 
74 UTL_NS_END;
Named object mix-in.
Definition: NamedObjectMI.h:24
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
MUTual EXclusion device.
Definition: Mutex.h:27
Condition variable.
Definition: ConditionVar.h:30
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition: macros.h:358
Root of UTL++ class hierarchy.
Definition: Object.h:52
void init()
Initialize UTL++.