Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2800)

Unified Diff: base/atomic_flag.cc

Issue 276002: Add AtomicFlag class to base/...... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/atomic_flag.h ('k') | base/atomic_flag_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/atomic_flag.cc
===================================================================
--- base/atomic_flag.cc (revision 0)
+++ base/atomic_flag.cc (revision 0)
@@ -0,0 +1,28 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/atomic_flag.h"
+
+#include "base/dynamic_annotations.h"
+#include "base/logging.h"
+
+namespace base {
+
+void AtomicFlag::Set() {
+ DCHECK(!flag_);
+ // Set() method can't be called if the flag has already been set.
+
+ ANNOTATE_HAPPENS_BEFORE(&flag_);
+ base::subtle::Release_Store(&flag_, 1);
+}
+
+bool AtomicFlag::IsSet() const {
+ bool ret = base::subtle::Acquire_Load(&flag_) != 0;
+ if (ret) {
+ ANNOTATE_HAPPENS_AFTER(&flag_);
+ }
+ return ret;
+}
+
+} // namespace base
Property changes on: base/atomic_flag.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « base/atomic_flag.h ('k') | base/atomic_flag_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698