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

Side by Side Diff: Source/wtf/ThreadRestrictionVerifier.h

Issue 397733004: Allow assertions to be enabled in Blink Release builds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed config.gni. Minor cleanups. Created 6 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ThreadRestrictionVerifier_h 31 #ifndef ThreadRestrictionVerifier_h
32 #define ThreadRestrictionVerifier_h 32 #define ThreadRestrictionVerifier_h
33 33
34 #ifndef NDEBUG 34 #include "wtf/Assertions.h"
35 35
36 #include "wtf/Assertions.h" 36 #if ENABLE(ASSERT)
37
37 #include "wtf/Threading.h" 38 #include "wtf/Threading.h"
38 39
39 namespace WTF { 40 namespace WTF {
40 41
41 // Verifies that a class is used in a way that respects its lack of thread-safet y. 42 // Verifies that a class is used in a way that respects its lack of thread-safet y.
42 // The default mode is to verify that the object will only be used on a single t hread. The 43 // The default mode is to verify that the object will only be used on a single t hread. The
43 // thread gets captured when setShared(true) is called. 44 // thread gets captured when setShared(true) is called.
44 // The mode may be changed by calling useMutexMode (or turnOffVerification). 45 // The mode may be changed by calling useMutexMode (or turnOffVerification).
45 class ThreadRestrictionVerifier { 46 class ThreadRestrictionVerifier {
46 public: 47 public:
47 ThreadRestrictionVerifier() 48 ThreadRestrictionVerifier()
48 : m_shared(false) 49 : m_shared(false)
49 , m_owningThread(0) 50 , m_owningThread(0)
50 { 51 {
51 } 52 }
52 53
53 // Indicates that the object may (or may not) be owned by more than one plac e. 54 // Indicates that the object may (or may not) be owned by more than one plac e.
54 void setShared(bool shared) 55 void setShared(bool shared)
55 { 56 {
56 #if ASSERT_ENABLED
Ken Russell (switch to Gerrit) 2014/07/15 23:25:35 This entire file was essentially guarded under ASS
57 bool previouslyShared = m_shared; 57 bool previouslyShared = m_shared;
58 #endif
59 m_shared = shared; 58 m_shared = shared;
60 59
61 if (!m_shared) 60 if (!m_shared)
62 return; 61 return;
63 62
64 ASSERT(shared != previouslyShared); 63 ASSERT(shared != previouslyShared);
65 // Capture the current thread to verify that subsequent ref/deref happen on this thread. 64 // Capture the current thread to verify that subsequent ref/deref happen on this thread.
66 m_owningThread = currentThread(); 65 m_owningThread = currentThread();
67 } 66 }
68 67
(...skipping 10 matching lines...) Expand all
79 bool m_shared; 78 bool m_shared;
80 79
81 // Used by SingleThreadVerificationMode 80 // Used by SingleThreadVerificationMode
82 ThreadIdentifier m_owningThread; 81 ThreadIdentifier m_owningThread;
83 }; 82 };
84 83
85 } 84 }
86 85
87 #endif // !NDEBUG 86 #endif // !NDEBUG
88 #endif // ThreadRestrictionVerifier_h 87 #endif // ThreadRestrictionVerifier_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698