26 |
|
|
27 |
#include "Mutex.h" |
#include "Mutex.h" |
28 |
|
|
29 |
|
#if defined(WIN32) |
30 |
|
#include <windows.h> |
31 |
|
typedef HANDLE win32thread_mutex_t; |
32 |
|
|
33 |
|
typedef struct |
34 |
|
{ |
35 |
|
int waiters_count_; |
36 |
|
// Number of waiting threads. |
37 |
|
|
38 |
|
CRITICAL_SECTION waiters_count_lock_; |
39 |
|
// Serialize access to <waiters_count_>. |
40 |
|
|
41 |
|
HANDLE sema_; |
42 |
|
// Semaphore used to queue up threads waiting for the condition to |
43 |
|
// become signaled. |
44 |
|
|
45 |
|
HANDLE waiters_done_; |
46 |
|
// An auto-reset event used by the broadcast/signal thread to wait |
47 |
|
// for all the waiting thread(s) to wake up and be released from the |
48 |
|
// semaphore. |
49 |
|
|
50 |
|
size_t was_broadcast_; |
51 |
|
// Keeps track of whether we were broadcasting or signaling. This |
52 |
|
// allows us to optimize the code if we're just signaling. |
53 |
|
} win32thread_cond_t; |
54 |
|
#endif |
55 |
|
|
56 |
namespace LinuxSampler { |
namespace LinuxSampler { |
57 |
|
|
58 |
/** |
/** |
137 |
bool GetUnsafe(); |
bool GetUnsafe(); |
138 |
|
|
139 |
protected: |
protected: |
140 |
|
#if defined(WIN32) |
141 |
|
win32thread_cond_t __win32_true_condition; |
142 |
|
win32thread_cond_t __win32_false_condition; |
143 |
|
#else |
144 |
pthread_cond_t __posix_true_condition; |
pthread_cond_t __posix_true_condition; |
145 |
pthread_cond_t __posix_false_condition; |
pthread_cond_t __posix_false_condition; |
146 |
|
#endif |
147 |
bool bCondition; |
bool bCondition; |
148 |
}; |
}; |
149 |
|
|