blob: ca5c0a82837070742e63914f79e57d924721efd4 [file] [log] [blame]
James Robinson646469d2014-10-03 15:33:28 -07001// 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
3// found in the LICENSE file.
4
5#include "base/synchronization/cancellation_flag.h"
6
7#include "base/logging.h"
8
9namespace base {
10
11void CancellationFlag::Set() {
12#if !defined(NDEBUG)
13 DCHECK_EQ(set_on_, PlatformThread::CurrentId());
14#endif
15 base::subtle::Release_Store(&flag_, 1);
16}
17
18bool CancellationFlag::IsSet() const {
19 return base::subtle::Acquire_Load(&flag_) != 0;
20}
21
James Robinson0fae0002015-05-05 16:31:51 -070022void CancellationFlag::UnsafeResetForTesting() {
23 base::subtle::Release_Store(&flag_, 0);
24}
25
James Robinson646469d2014-10-03 15:33:28 -070026} // namespace base