12#if defined(_WIN32) && !defined(ICE_HAS_WIN32_CONDVAR)
15namespace IceUtilInternal
28 bool timedWait(
const IceUtil::Time&)
const;
29 void post(
int = 1)
const;
44template <
class T>
class Monitor;
84 template <
typename Lock>
inline void
85 wait(
const Lock& lock)
const
91 waitImpl(lock._mutex);
101 template <
typename Lock>
inline bool
108 return timedWaitImpl(lock._mutex, timeout);
119#if defined(_WIN32) && !defined(ICE_HAS_WIN32_CONDVAR)
121 template <
typename M>
void
122 waitImpl(
const M& mutex)
const
126 typedef typename M::LockState LockState;
142 template <
typename M>
bool
143 timedWaitImpl(
const M& mutex,
const Time& timeout)
const
147 typedef typename M::LockState LockState;
154 bool rc = timedDowait(timeout);
167 template <
typename M>
void waitImpl(
const M&)
const;
168 template <
typename M>
bool timedWaitImpl(
const M&,
const Time&)
const;
173# ifdef ICE_HAS_WIN32_CONDVAR
174 mutable CONDITION_VARIABLE _cond;
177 void preWait()
const;
178 void postWait(
bool)
const;
179 bool timedDowait(
const Time&)
const;
183 IceUtilInternal::Semaphore _gate;
184 IceUtilInternal::Semaphore _queue;
185 mutable long _blocked;
186 mutable long _unblocked;
193 mutable State _state;
196 mutable pthread_cond_t _cond;
203# ifdef ICE_HAS_WIN32_CONDVAR
205template <
typename M>
inline void
206Cond::waitImpl(
const M& mutex)
const
208 typedef typename M::LockState LockState;
212 BOOL ok = SleepConditionVariableCS(&_cond, state.mutex, INFINITE);
217 throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
221template <
typename M>
inline bool
222Cond::timedWaitImpl(
const M& mutex,
const Time& timeout)
const
225 if(msTimeout < 0 || msTimeout > 0x7FFFFFFF)
227 throw IceUtil::InvalidTimeoutException(__FILE__, __LINE__, timeout);
230 typedef typename M::LockState LockState;
234 BOOL ok = SleepConditionVariableCS(&_cond, state.mutex,
static_cast<DWORD
>(msTimeout));
239 DWORD err = GetLastError();
241 if(err != ERROR_TIMEOUT)
243 throw ThreadSyscallException(__FILE__, __LINE__, err);
253template <
typename M>
inline void
254Cond::waitImpl(
const M& mutex)
const
256 typedef typename M::LockState LockState;
260 int rc = pthread_cond_wait(&_cond, state.mutex);
265 throw ThreadSyscallException(__FILE__, __LINE__, rc);
269template <
typename M>
inline bool
270Cond::timedWaitImpl(
const M& mutex,
const Time& timeout)
const
274 throw InvalidTimeoutException(__FILE__, __LINE__, timeout);
277 typedef typename M::LockState LockState;
293 ts.tv_sec = tv.tv_sec;
294 ts.tv_nsec = tv.tv_usec * 1000;
295 int rc = pthread_cond_timedwait(&_cond, state.mutex, &ts);
306 throw ThreadSyscallException(__FILE__, __LINE__, rc);
#define ICE_API
Definition Config.h:197
void wait(const Lock &lock) const
Definition Cond.h:85
bool timedWait(const Lock &lock, const Time &timeout) const
Definition Cond.h:102
Definition ThreadException.h:27
static Time microSeconds(Int64)
static Time now(Clock=Realtime)
@ Realtime
Definition Time.h:27
@ Monotonic
Definition Time.h:27
noncopyable()
Definition Config.h:316
Definition Optional.h:1095
long long Int64
Definition Config.h:342