1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgnamespace webrtc {
1587beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass CriticalSectionWrapper;
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
1887beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.orgclass ConditionVariableWrapper {
1987beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org public:
2087beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // Factory method, constructor disabled.
2187beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  static ConditionVariableWrapper* CreateConditionVariable();
22b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
2387beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  virtual ~ConditionVariableWrapper() {}
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
2587beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // Calling thread will atomically release crit_sect and wait until next
2687beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // some other thread calls Wake() or WakeAll().
2787beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  virtual void SleepCS(CriticalSectionWrapper& crit_sect) = 0;
28b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
2987beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // Same as above but with a timeout.
3087beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  virtual bool SleepCS(CriticalSectionWrapper& crit_sect,
3187beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org                       unsigned long max_time_in_ms) = 0;
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
3387beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // Wakes one thread calling SleepCS().
3487beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  virtual void Wake() = 0;
35b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
3687beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  // Wakes all threads calling SleepCS().
3787beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org  virtual void WakeAll() = 0;
38b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
3987beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org
403b89e10f31160da35b408fd00cb8f89d2b08862dpbos@webrtc.org}  // namespace webrtc
41b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
4287beb441ccf697d1f2677ceaccde7fc153c6fdd9phoglund@webrtc.org#endif  // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
43