OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_BASE_COMPLETION_EVENT_H_ | 5 #ifndef CC_BASE_COMPLETION_EVENT_H_ |
6 #define CC_BASE_COMPLETION_EVENT_H_ | 6 #define CC_BASE_COMPLETION_EVENT_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 // Used for making blocking calls from one thread to another. Use only when | 15 // Used for making blocking calls from one thread to another. Use only when |
16 // absolutely certain that doing-so will not lead to a deadlock. | 16 // absolutely certain that doing-so will not lead to a deadlock. |
17 // | 17 // |
18 // It is safe to destroy this object as soon as Wait() returns. | 18 // It is safe to destroy this object as soon as Wait() returns. |
19 class CompletionEvent { | 19 class CompletionEvent { |
20 public: | 20 public: |
21 CompletionEvent() | 21 CompletionEvent() |
22 : event_(false /* manual_reset */, false /* initially_signaled */) { | 22 : event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 23 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
23 #if DCHECK_IS_ON() | 24 #if DCHECK_IS_ON() |
24 waited_ = false; | 25 waited_ = false; |
25 signaled_ = false; | 26 signaled_ = false; |
26 #endif | 27 #endif |
27 } | 28 } |
28 | 29 |
29 ~CompletionEvent() { | 30 ~CompletionEvent() { |
30 #if DCHECK_IS_ON() | 31 #if DCHECK_IS_ON() |
31 DCHECK(waited_); | 32 DCHECK(waited_); |
32 DCHECK(signaled_); | 33 DCHECK(signaled_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #if DCHECK_IS_ON() | 66 #if DCHECK_IS_ON() |
66 // Used to assert that Wait() and Signal() are each called exactly once. | 67 // Used to assert that Wait() and Signal() are each called exactly once. |
67 bool waited_; | 68 bool waited_; |
68 bool signaled_; | 69 bool signaled_; |
69 #endif | 70 #endif |
70 }; | 71 }; |
71 | 72 |
72 } // namespace cc | 73 } // namespace cc |
73 | 74 |
74 #endif // CC_BASE_COMPLETION_EVENT_H_ | 75 #endif // CC_BASE_COMPLETION_EVENT_H_ |
OLD | NEW |