15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)/*
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *  Use of this source code is governed by a BSD-style license
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) *  that can be found in the LICENSE file in the root of the source
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *  tree. An additional intellectual property rights grant can be found
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *  in the file PATENTS.  All contributing project authors may
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *  be found in the AUTHORS file in the root of the source tree.
9c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch */
10effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
13effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace webrtc {
15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class CriticalSectionWrapper;
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
17effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass ConditionVariableWrapper
18116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)public:
206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    // Factory method, constructor disabled.
21effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    static ConditionVariableWrapper* CreateConditionVariable();
22effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual ~ConditionVariableWrapper() {}
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // Calling thread will atomically release critSect and wait until next
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // some other thread calls Wake() or WakeAll().
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual void SleepCS(CriticalSectionWrapper& critSect) = 0;
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // Same as above but with a timeout.
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    virtual bool SleepCS(CriticalSectionWrapper& critSect,
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         unsigned long maxTimeInMS) = 0;
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
33effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    // Wakes one thread calling SleepCS().
3423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    virtual void Wake() = 0;
35effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    // Wakes all threads calling SleepCS().
37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    virtual void WakeAll() = 0;
3823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)};
3923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)} // namespace webrtc
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)