Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ | 5 #ifndef BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ |
| 6 #define BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ | 6 #define BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #if !defined(NDEBUG) | 22 #if !defined(NDEBUG) |
| 23 set_on_ = PlatformThread::CurrentId(); | 23 set_on_ = PlatformThread::CurrentId(); |
| 24 #endif | 24 #endif |
| 25 } | 25 } |
| 26 ~CancellationFlag() {} | 26 ~CancellationFlag() {} |
| 27 | 27 |
| 28 // Set the flag. May only be called on the thread which owns the object. | 28 // Set the flag. May only be called on the thread which owns the object. |
| 29 void Set(); | 29 void Set(); |
| 30 bool IsSet() const; // Returns true iff the flag was set. | 30 bool IsSet() const; // Returns true iff the flag was set. |
| 31 | 31 |
| 32 void UnsafeResetForTesting(); | |
|
Nico
2015/04/09 20:10:15
add method comment (explain how this is unsafe)
michaeln
2015/04/09 21:48:39
Done (but not sure what to say really)
// For s
| |
| 33 | |
| 32 private: | 34 private: |
| 33 base::subtle::Atomic32 flag_; | 35 base::subtle::Atomic32 flag_; |
| 34 #if !defined(NDEBUG) | 36 #if !defined(NDEBUG) |
| 35 PlatformThreadId set_on_; | 37 PlatformThreadId set_on_; |
| 36 #endif | 38 #endif |
| 37 | 39 |
| 38 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); | 40 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 } // namespace base | 43 } // namespace base |
| 42 | 44 |
| 43 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ | 45 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ |
| OLD | NEW |