MCPcopy Create free account
hub / github.com/apache/impala / SpinLockWait

Function SpinLockWait

be/src/gutil/spinlock_internal.cc:61–78  ·  view source on GitHub ↗

See spinlock_internal.h for spec.

Source from the content-addressed store, hash-verified

59
60// See spinlock_internal.h for spec.
61int32 SpinLockWait(volatile Atomic32 *w, int n,
62 const SpinLockWaitTransition trans[]) {
63 int32 v;
64 bool done = false;
65 for (int loop = 0; !done; loop++) {
66 v = base::subtle::Acquire_Load(w);
67 int i;
68 for (i = 0; i != n && v != trans[i].from; i++) {
69 }
70 if (i == n) {
71 SpinLockDelay(w, v, loop); // no matching transition
72 } else if (trans[i].to == v || // null transition
73 base::subtle::Acquire_CompareAndSwap(w, v, trans[i].to) == v) {
74 done = trans[i].done;
75 }
76 }
77 return v;
78}
79
80// Return a suggested delay in nanoseconds for iteration number "loop"
81static int SuggestedDelayNS(int loop) {

Callers 1

GoogleOnceInternalInitFunction · 0.85

Calls 3

Acquire_LoadFunction · 0.70
SpinLockDelayFunction · 0.70
Acquire_CompareAndSwapFunction · 0.70

Tested by

no test coverage detected