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 CCCompletionEvent_h | 5 #ifndef CCCompletionEvent_h |
6 #define CCCompletionEvent_h | 6 #define CCCompletionEvent_h |
7 | 7 |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 // Used for making blocking calls from one thread to another. Use only when | 13 // Used for making blocking calls from one thread to another. Use only when |
14 // absolutely certain that doing-so will not lead to a deadlock. | 14 // absolutely certain that doing-so will not lead to a deadlock. |
15 // | 15 // |
16 // It is safe to destroy this object as soon as wait() returns. | 16 // It is safe to destroy this object as soon as wait() returns. |
17 class CCCompletionEvent { | 17 class CompletionEvent { |
18 public: | 18 public: |
19 CCCompletionEvent() | 19 CompletionEvent() |
20 : m_event(false /* manual_reset */, false /* initially_signaled */) | 20 : m_event(false /* manual_reset */, false /* initially_signaled */) |
21 { | 21 { |
22 #ifndef NDEBUG | 22 #ifndef NDEBUG |
23 m_waited = false; | 23 m_waited = false; |
24 m_signaled = false; | 24 m_signaled = false; |
25 #endif | 25 #endif |
26 } | 26 } |
27 | 27 |
28 ~CCCompletionEvent() | 28 ~CompletionEvent() |
29 { | 29 { |
30 ASSERT(m_waited); | 30 ASSERT(m_waited); |
31 ASSERT(m_signaled); | 31 ASSERT(m_signaled); |
32 } | 32 } |
33 | 33 |
34 void wait() | 34 void wait() |
35 { | 35 { |
36 ASSERT(!m_waited); | 36 ASSERT(!m_waited); |
37 #ifndef NDEBUG | 37 #ifndef NDEBUG |
38 m_waited = true; | 38 m_waited = true; |
(...skipping 16 matching lines...) Expand all Loading... |
55 #ifndef NDEBUG | 55 #ifndef NDEBUG |
56 // Used to assert that wait() and signal() are each called exactly once. | 56 // Used to assert that wait() and signal() are each called exactly once. |
57 bool m_waited; | 57 bool m_waited; |
58 bool m_signaled; | 58 bool m_signaled; |
59 #endif | 59 #endif |
60 }; | 60 }; |
61 | 61 |
62 } | 62 } |
63 | 63 |
64 #endif | 64 #endif |
OLD | NEW |