struct Atomic::Flag
inherits Struct
¶
An atomic flag, that can be set or not.
Concurrency safe. If many fibers try to set the atomic in parallel, only one will succeed.
Example:
flag = Atomic::Flag.new
flag.test_and_set # => true
flag.test_and_set # => false
flag.clear
flag.test_and_set # => true
Class methods¶
Methods¶
#test_and_set : Bool
¶
: Bool
Atomically tries to set the flag. Only succeeds and returns true
if the
flag wasn't previously set; returns false
otherwise.