| 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 // For subtle reasons that may be different on different architectures, |
| 33 // a different thread testing IsSet() may erroneously read 'true' after |
| 34 // this method has been called. |
| 35 void UnsafeResetForTesting(); |
| 36 |
| 32 private: | 37 private: |
| 33 base::subtle::Atomic32 flag_; | 38 base::subtle::Atomic32 flag_; |
| 34 #if !defined(NDEBUG) | 39 #if !defined(NDEBUG) |
| 35 PlatformThreadId set_on_; | 40 PlatformThreadId set_on_; |
| 36 #endif | 41 #endif |
| 37 | 42 |
| 38 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); | 43 DISALLOW_COPY_AND_ASSIGN(CancellationFlag); |
| 39 }; | 44 }; |
| 40 | 45 |
| 41 } // namespace base | 46 } // namespace base |
| 42 | 47 |
| 43 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ | 48 #endif // BASE_SYNCHRONIZATION_CANCELLATION_FLAG_H_ |
| OLD | NEW |