struct Syn::Core::AtomicLock
- Syn::Core::AtomicLock
- Struct
- Value
- Object
Overview
Similar to Atomic::Flag
but adds memory barriers (fences) in addition
to the atomic instructions, and relies on the acquire/release memory
ordering that should be suitable for locks.
Basically, the atomic instructions tell the CPU to use an atomic operand on the CPU and usually their memory ordering also serves as hints to the compiler (here LLVM) to not reorder instructions across the atomic. The fences add another level of protection against weak CPU architectures (such as ARM), telling them to not reorder instructions across the fences at runtime.
The memory fences should be noop and optimized away on non weak CPU architectures such as x86/64.
Defined in:
core/atomic_lock.crConstructors
Instance Method Summary
-
#acquire? : Bool
Acquires the lock.
-
#release : Nil
Releases the lock.
Constructor Detail
Instance Method Detail
Acquires the lock. The operation is atomic, and any operation that happens after the acquire won't be reordered before the acquire, either during compilation or live at runtime on weak CPU architectures.
Releases the lock. The operation is atomic, and any operation that happens before the release won't be reordered after the release, either during compilation or live at runtime on weak CPU architectures.