Ejemplo n.º 1
0
void OSCondVarOld::TimedWait(DWORD dwMilliseconds)
{
    Event *waiting_event;
    HANDLE handle;
    {
        Scoped_Lock_Protect(internal_lock_);
        if (RUNNING != run_state_) return;
        waiting_event = GetEventForWaiting();
        handle = waiting_event->handle();
    }

    {
        Scoped_Unlock_Protect(user_lock_);
        WaitForSingleObject(handle, dwMilliseconds);

        Scoped_Lock_Protect(internal_lock_);
        RecycleEvent(waiting_event);
    }
}
Ejemplo n.º 2
0
void ConditionVariable::TimedWait(int millSeconds) {
    Event* waiting_event;
    HANDLE handle;
    {
        AutoLock auto_lock(internal_lock_);
        if (RUNNING != run_state_) return;  // Destruction in progress.
        waiting_event = GetEventForWaiting();
        handle = waiting_event->handle();
        //DCHECK(handle);
    }  // Release internal_lock.

    {
        AutoUnlock unlock(user_lock_);  // Release caller's lock
        WaitForSingleObject(handle, static_cast<DWORD>(millSeconds));
        // Minimize spurious signal creation window by recycling asap.
        AutoLock auto_lock(internal_lock_);
        RecycleEvent(waiting_event);
        // Release internal_lock_
    }  // Reacquire callers lock to depth at entry.
}