aboutsummaryrefslogtreecommitdiff
path: root/src/base/spinlock_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/spinlock_internal.h')
-rw-r--r--src/base/spinlock_internal.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/base/spinlock_internal.h b/src/base/spinlock_internal.h
index aa47e67..4494260 100644
--- a/src/base/spinlock_internal.h
+++ b/src/base/spinlock_internal.h
@@ -1,4 +1,3 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
/* Copyright (c) 2010, Google Inc.
* All rights reserved.
*
@@ -43,6 +42,20 @@
namespace base {
namespace internal {
+// SpinLockWait() waits until it can perform one of several transitions from
+// "from" to "to". It returns when it performs a transition where done==true.
+struct SpinLockWaitTransition {
+ int32 from;
+ int32 to;
+ bool done;
+};
+
+// Wait until *w can transition from trans[i].from to trans[i].to for some i
+// satisfying 0<=i<n && trans[i].done, atomically make the transition,
+// then return the old value of *w. Make any other atomic tranistions
+// where !trans[i].done, but continue waiting.
+int32 SpinLockWait(volatile Atomic32 *w, int n,
+ const SpinLockWaitTransition trans[]);
void SpinLockWake(volatile Atomic32 *w, bool all);
void SpinLockDelay(volatile Atomic32 *w, int32 value, int loop);