event.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_WEBRTC_OVERRIDES_RTC_BASE_EVENT_H_
  5. #define THIRD_PARTY_WEBRTC_OVERRIDES_RTC_BASE_EVENT_H_
  6. #include "base/macros.h"
  7. #include "base/synchronization/waitable_event.h"
  8. #include "base/threading/thread_restrictions.h"
  9. #include "third_party/webrtc/rtc_base/system/rtc_export.h"
  10. namespace rtc {
  11. // Overrides WebRTC's internal event implementation to use Chromium's.
  12. class RTC_EXPORT Event {
  13. public:
  14. static const int kForever = -1;
  15. Event();
  16. Event(bool manual_reset, bool initially_signaled);
  17. ~Event();
  18. void Set();
  19. void Reset();
  20. // Wait for the event to become signaled, for the specified number of
  21. // milliseconds. To wait indefinetly, pass kForever.
  22. bool Wait(int give_up_after_ms);
  23. bool Wait(int give_up_after_ms, int /*warn_after_ms*/) {
  24. return Wait(give_up_after_ms);
  25. }
  26. private:
  27. base::WaitableEvent event_;
  28. DISALLOW_COPY_AND_ASSIGN(Event);
  29. };
  30. // Pull ScopedAllowBaseSyncPrimitives(ForTesting) into the rtc namespace.
  31. // Managing what types in WebRTC are allowed to use
  32. // ScopedAllowBaseSyncPrimitives, is done via thread_restrictions.h.
  33. using ScopedAllowBaseSyncPrimitives = base::ScopedAllowBaseSyncPrimitives;
  34. using ScopedAllowBaseSyncPrimitivesForTesting =
  35. base::ScopedAllowBaseSyncPrimitivesForTesting;
  36. } // namespace rtc
  37. #endif // THIRD_PARTY_WEBRTC_OVERRIDES_RTC_BASE_EVENT_H_