libfoedus-core
FOEDUS Core Library
|
A simple spinlock using a boolean field. More...
A simple spinlock using a boolean field.
As the name suggests, this spinlock implementation is not scalable at all. It's the dumbest implementation of lock, which might cause cacheline invalidation storm when contended. However, in many places it's enough and also the simplicity helps. You just need memory for one bool, that's it. It trivially works for a shared memory, too.
Use this object where you don't expect much contention.
Definition at line 40 of file dumb_spinlock.hpp.
#include <dumb_spinlock.hpp>
Public Member Functions | |
DumbSpinlock (bool *locked, bool lock_initially=true) | |
~DumbSpinlock () | |
automatically unlocks when out of scope. More... | |
bool | is_locked_by_me () const |
void | lock () |
Locks it if I haven't locked it yet. More... | |
bool | try_lock () |
try-version of the lock. More... | |
void | unlock () |
Unlocks it if I locked it. More... | |
|
inline |
Definition at line 42 of file dumb_spinlock.hpp.
References lock().
|
inline |
automatically unlocks when out of scope.
Definition at line 48 of file dumb_spinlock.hpp.
References unlock().
|
inline |
Definition at line 50 of file dumb_spinlock.hpp.
Referenced by foedus::storage::masstree::GrowFirstLayerRoot::run().
|
inline |
Locks it if I haven't locked it yet.
This method is idempotent.
Definition at line 53 of file dumb_spinlock.hpp.
References SPINLOCK_WHILE, and try_lock().
Referenced by DumbSpinlock().
|
inline |
try-version of the lock.
Definition at line 61 of file dumb_spinlock.hpp.
References ASSERT_ND.
Referenced by lock(), and foedus::storage::masstree::GrowFirstLayerRoot::run().
|
inline |
Unlocks it if I locked it.
This method is idempotent. You can safely call many times.
Definition at line 78 of file dumb_spinlock.hpp.
References ASSERT_ND, and foedus::assorted::memory_fence_acq_rel().
Referenced by ~DumbSpinlock().