Specifies how memory accesses, including non atomic, are to be reordered around atomics. Follows the C/C++ semantics: https://en.cppreference.com/w/c/atomic/memory_order.
By default atomics use the sequentially consistent ordering, which has the strongest guarantees. If all you need is to increment a counter, a relaxed ordering may be enough. If you need to synchronize access to other memory (e.g. locks) you may try the acquire/release semantics that may be faster on some architectures (e.g. X86) but remember that an acquire must be paired with a release for the ordering to be guaranteed.
The code generation always enforces the selected memory order, even on weak CPU architectures (e.g. ARM32), with the exception of the Relaxed memory order where only the operation itself is atomic.
2 4 5 6 7 Returns true if this enum value equals Acquire
Returns true if this enum value equals AcquireRelease
Returns true if this enum value equals Relaxed
Returns true if this enum value equals Release
Returns true if this enum value equals SequentiallyConsistent
Enum
Enum
Enum
Enum
Comparable(Enum)
Value
Object
Object
Object
Returns true if this enum value equals AcquireRelease
Returns true if this enum value equals SequentiallyConsistent
© 2012–2026 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.19.0/Atomic/Ordering.html