#include <SpinLock.h>
Public Types | |
enum class | BarrierType |
Public Member Functions | |
SpinLock (BarrierType barrier=BarrierType::eDEFAULT) | |
Implementation based on http://en.cppreference.com/w/cpp/atomic/atomic_flag
About to run tests to compare performance numbers. But this maybe useful for at least some(many) cases.
"A synchronization operation without an associated memory location is a fence and can be either an acquire fence, a release fence, or both an acquire and release fence"
Since a spinlock once acquired - can be used to assume assocated data (the data protected by the spinlock mutex) is up to date with respect to other threads and acquire is needed on the lock. And to assure any changes made with the lock are seen in other threads a release atomic_fence() is required on the unlock.
This is the DEFAULT behavior we provide with the default BarrierType - eReleaseAcquire
Definition at line 62 of file SpinLock.h.
|
strong |
Definition at line 70 of file SpinLock.h.
Stroika::Foundation::Execution::SpinLock::SpinLock | ( | BarrierType | barrier = BarrierType::eDEFAULT | ) |
In typical usage, one would use a SpinLock as a mutex, and expect it to create a memory fence. However, sometimes you want to spinlock and handle the memory ordering yourself. So that feature is optional (defaulting to the safer, but slower - true).
Definition at line 13 of file SpinLock.inl.