You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_
  11. #define SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_
  12. namespace webrtc {
  13. enum EventTypeWrapper { kEventSignaled = 1, kEventTimeout = 2 };
  14. #define WEBRTC_EVENT_INFINITE 0xffffffff
  15. class EventWrapper {
  16. public:
  17. // Factory method. Constructor disabled.
  18. static EventWrapper* Create();
  19. virtual ~EventWrapper() {}
  20. // Releases threads who are calling Wait() and has started waiting. Please
  21. // note that a thread calling Wait() will not start waiting immediately.
  22. // assumptions to the contrary is a very common source of issues in
  23. // multithreaded programming.
  24. // Set is sticky in the sense that it will release at least one thread
  25. // either immediately or some time in the future.
  26. virtual bool Set() = 0;
  27. // Puts the calling thread into a wait state. The thread may be released
  28. // by a Set() call depending on if other threads are waiting and if so on
  29. // timing. The thread that was released will reset the event before leaving
  30. // preventing more threads from being released. If multiple threads
  31. // are waiting for the same Set(), only one (random) thread is guaranteed to
  32. // be released. It is possible that multiple (random) threads are released
  33. // Depending on timing.
  34. //
  35. // |max_time| is the maximum time to wait in milliseconds or
  36. // WEBRTC_EVENT_INFINITE to wait infinitely.
  37. virtual EventTypeWrapper Wait(unsigned long max_time) = 0;
  38. };
  39. } // namespace webrtc
  40. #endif // SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_