niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ |
| 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ |
| 13 | |
| 14 | namespace webrtc { |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 15 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | class CriticalSectionWrapper; |
| 17 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 18 | class ConditionVariableWrapper { |
| 19 | public: |
| 20 | // Factory method, constructor disabled. |
| 21 | static ConditionVariableWrapper* CreateConditionVariable(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 23 | virtual ~ConditionVariableWrapper() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 25 | // Calling thread will atomically release crit_sect and wait until next |
| 26 | // some other thread calls Wake() or WakeAll(). |
| 27 | virtual void SleepCS(CriticalSectionWrapper& crit_sect) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 29 | // Same as above but with a timeout. |
| 30 | virtual bool SleepCS(CriticalSectionWrapper& crit_sect, |
| 31 | unsigned long max_time_in_ms) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 33 | // Wakes one thread calling SleepCS(). |
| 34 | virtual void Wake() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 36 | // Wakes all threads calling SleepCS(). |
| 37 | virtual void WakeAll() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | }; |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 39 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 40 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 42 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_ |