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 // Intended to help with testing. | |
| 33 void UnsafeReset(); | |
|
jam
2015/04/08 20:34:27
nit: testing methods need to end with ForTesting()
michaeln
2015/04/08 21:57:25
Done.
| |
| 34 | |
| 32 private: | 35 private: |
| 33 base::subtle::Atomic32 flag_; | 36 base::subtle::Atomic32 flag_; |
| 34 #if !defined(NDEBUG) | 37 #if !defined(NDEBUG) |
| 35 PlatformThreadId set_on_; | 38 PlatformThreadId set_on_; |
| 36 #endif | 39 #endif |
| 37 | 40 |
| 38 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); | 41 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 } // namespace base | 44 } // namespace base |
| 42 | 45 |
| 43 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ | 46 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ |
| OLD | NEW |