Esempio n. 1
0
bool sys::ConditionVarDataWin32::wait(HANDLE externalMutex, double timeout)
{
    if (timeout == 0)
    {
        wait(externalMutex);
        return true;
    }

    // Increment # waiting
    {
        const ScopedCriticalSection lock(mNumWaitersCS);
        ++mNumWaiters;
    }

    // Atomically release the mutex and wait on the semaphore until signal()
    // or broadcast() are called by another thread or we time out
    switch (SignalObjectAndWait(externalMutex,
                                mSemaphore, 
                                static_cast<DWORD>(timeout * 1000), 
                                FALSE))
    {
    case WAIT_OBJECT_0:
        waitImpl(externalMutex);
        return true;
    case WAIT_TIMEOUT:
        return false;
    default:
        throw sys::SystemException("SignalObjectAndWait() failed");
    }
}
Esempio n. 2
0
bool SynchronizableMulti::wait(int id, bool front, long seconds,
                               long long nanosecs) {
  struct timespec ts;
  gettime(CLOCK_REALTIME, &ts);
  ts.tv_sec += seconds;
  ts.tv_nsec += nanosecs;
  return waitImpl(id, front, &ts);
}
Esempio n. 3
0
bool SynchronizableMulti::wait(int id, int q, bool front, long seconds,
                               long long nanosecs) {
  struct timespec ts;
  Timer::GetRealtimeTime(ts);
  ts.tv_sec += seconds;
  ts.tv_nsec += nanosecs;
  return waitImpl(id, q, front, &ts);
}
Esempio n. 4
0
void sys::ConditionVarDataWin32::wait(HANDLE externalMutex)
{
    // Increment # waiting
    {
        const ScopedCriticalSection lock(mNumWaitersCS);
        ++mNumWaiters;
    }

    // Atomically release the mutex and wait on the semaphore until signal()
    // or broadcast() are called by another thread
    if (SignalObjectAndWait(externalMutex, mSemaphore, INFINITE, FALSE) != 
        WAIT_OBJECT_0)
    {
        throw sys::SystemException("SignalObjectAndWait() failed");
    }

    waitImpl(externalMutex);
}
Esempio n. 5
0
void SynchronizableMulti::wait(int id, bool front) {
  waitImpl(id, front, NULL);
}
void SynchronizableMulti::wait(int id, bool front) {
  waitImpl(id, front, nullptr);
}