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 #include "base/synchronization/cancellation_flag.h" | 5 #include "base/synchronization/atomic_flag.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
11 void CancellationFlag::Set() { | 11 AtomicFlag::AtomicFlag() = default; |
12 #if !defined(NDEBUG) | 12 |
13 DCHECK_EQ(set_on_, PlatformThread::CurrentId()); | 13 void AtomicFlag::Set() { |
14 #endif | 14 DCHECK(thread_checker_.CalledOnValidThread()); |
15 base::subtle::Release_Store(&flag_, 1); | 15 base::subtle::Release_Store(&flag_, 1); |
16 } | 16 } |
17 | 17 |
18 bool CancellationFlag::IsSet() const { | 18 bool AtomicFlag::IsSet() const { |
19 return base::subtle::Acquire_Load(&flag_) != 0; | 19 return base::subtle::Acquire_Load(&flag_) != 0; |
20 } | 20 } |
21 | 21 |
22 void CancellationFlag::UnsafeResetForTesting() { | 22 void AtomicFlag::UnsafeResetForTesting() { |
23 base::subtle::Release_Store(&flag_, 0); | 23 base::subtle::Release_Store(&flag_, 0); |
24 } | 24 } |
25 | 25 |
26 } // namespace base | 26 } // namespace base |
OLD | NEW |