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

Unified Diff: webrtc/base/atomicops.h

Issue 1246073002: Implement store as an explicit atomic operation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: s/Increment/ReleaseStore Created 5 years, 5 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 | « no previous file | webrtc/base/refcount.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/atomicops.h
diff --git a/webrtc/base/atomicops.h b/webrtc/base/atomicops.h
index 80b212444305143229b0de5bc54f4bbaa0c7ddeb..a863566a670aad0b3d4904f0040c3c20ad845461 100644
--- a/webrtc/base/atomicops.h
+++ b/webrtc/base/atomicops.h
@@ -31,10 +31,10 @@ class AtomicOps {
static int Decrement(volatile int* i) {
return ::InterlockedDecrement(reinterpret_cast<volatile LONG*>(i));
}
- static int Load(volatile const int* i) {
+ static int AcquireLoad(volatile const int* i) {
return *i;
}
- static void Store(volatile int* i, int value) {
+ static void ReleaseStore(volatile int* i, int value) {
*i = value;
}
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
@@ -49,13 +49,11 @@ class AtomicOps {
static int Decrement(volatile int* i) {
return __sync_sub_and_fetch(i, 1);
}
- static int Load(volatile const int* i) {
- // Adding 0 is a no-op, so const_cast is fine.
- return __sync_add_and_fetch(const_cast<volatile int*>(i), 0);
+ static int AcquireLoad(volatile const int* i) {
+ return __atomic_load_n(i, __ATOMIC_ACQUIRE);
}
- static void Store(volatile int* i, int value) {
- __sync_synchronize();
- *i = value;
+ static void ReleaseStore(volatile int* i, int value) {
+ __atomic_store_n(i, value, __ATOMIC_RELEASE);
}
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
return __sync_val_compare_and_swap(i, old_value, new_value);
« no previous file with comments | « no previous file | webrtc/base/refcount.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698