Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: cc/completion_event.h

Issue 11196014: Revert "cc: Switch to Chromium DCHECKs LOGs" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/checkerboard_draw_quad.cc ('k') | cc/damage_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "cc/dcheck.h"
11 10
12 namespace cc { 11 namespace cc {
13 12
14 // 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
15 // absolutely certain that doing-so will not lead to a deadlock. 14 // absolutely certain that doing-so will not lead to a deadlock.
16 // 15 //
17 // 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.
18 class CCCompletionEvent { 17 class CCCompletionEvent {
19 public: 18 public:
20 CCCompletionEvent() 19 CCCompletionEvent()
21 : m_event(false /* manual_reset */, false /* initially_signaled */) 20 : m_event(false /* manual_reset */, false /* initially_signaled */)
22 { 21 {
23 #if CC_DCHECK_ENABLED() 22 #ifndef NDEBUG
24 m_waited = false; 23 m_waited = false;
25 m_signaled = false; 24 m_signaled = false;
26 #endif 25 #endif
27 } 26 }
28 27
29 ~CCCompletionEvent() 28 ~CCCompletionEvent()
30 { 29 {
31 DCHECK(m_waited); 30 ASSERT(m_waited);
32 DCHECK(m_signaled); 31 ASSERT(m_signaled);
33 } 32 }
34 33
35 void wait() 34 void wait()
36 { 35 {
37 DCHECK(!m_waited); 36 ASSERT(!m_waited);
38 #if CC_DCHECK_ENABLED() 37 #ifndef NDEBUG
39 m_waited = true; 38 m_waited = true;
40 #endif 39 #endif
41 base::ThreadRestrictions::ScopedAllowWait allow_wait; 40 base::ThreadRestrictions::ScopedAllowWait allow_wait;
42 m_event.Wait(); 41 m_event.Wait();
43 } 42 }
44 43
45 void signal() 44 void signal()
46 { 45 {
47 DCHECK(!m_signaled); 46 ASSERT(!m_signaled);
48 #if CC_DCHECK_ENABLED() 47 #ifndef NDEBUG
49 m_signaled = true; 48 m_signaled = true;
50 #endif 49 #endif
51 m_event.Signal(); 50 m_event.Signal();
52 } 51 }
53 52
54 private: 53 private:
55 base::WaitableEvent m_event; 54 base::WaitableEvent m_event;
56 #if CC_DCHECK_ENABLED() 55 #ifndef NDEBUG
57 // 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.
58 bool m_waited; 57 bool m_waited;
59 bool m_signaled; 58 bool m_signaled;
60 #endif 59 #endif
61 }; 60 };
62 61
63 } 62 }
64 63
65 #endif 64 #endif
OLDNEW
« no previous file with comments | « cc/checkerboard_draw_quad.cc ('k') | cc/damage_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698