AtomicBool
public final class AtomicBool
-
Declaration
Swift
public typealias Pointer = AtomicBoolPointer
-
Declaration
Swift
public typealias RawValue = CAtomicBool
-
Declaration
Swift
public convenience init(_ initialValue: RawValue)
-
Atomically loads and returns the current value of the atomic variable pointed to by the receiver. The operation is atomic read operation.
Declaration
Swift
public func load(order: AtomicLoadMemoryOrder = .seqcst) -> RawValue
Parameters
order
The memory synchronization ordering for this operation.
Return Value
The value stored in the receiver.
-
Atomically replaces the value of the atomic variable pointed to by the receiver with
desired
. The operation is atomic write operation.Declaration
Swift
public func store(_ desired: RawValue, order: AtomicStoreMemoryOrder = .seqcst)
Parameters
desired
The value to replace the receiver with.
order
The memory synchronization ordering for this operation.
-
Atomically replaces the value pointed by the receiver with
desired
and returns the value the receiver held previously. The operation is read-modify-write operation.Declaration
Parameters
desired
The value to replace the receiver with.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Atomically compares the value pointed to by the receiver with the value pointed to by
expected
, and if those are equal, replaces the former withdesired
(performs read-modify-write operation). Otherwise, loads the actual value pointed to by the receiver into*expected
(performs load operation).Declaration
Parameters
expected
The value expected to be found in the receiver.
desired
The value to store in the receiver if it is as expected.
order
The memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
loadOrder
The memory synchronization ordering for the load operation if the comparison fails. Cannot specify stronger ordering than
order
.Return Value
The result of the comparison:
true
if current value was equal to*expected
,false
otherwise. -
Atomically compares the value pointed to by the receiver with the value pointed to by
expected
, and if those are equal, replaces the former withdesired
(performs read-modify-write operation). Otherwise, loads the actual value pointed to by the receiver into*expected
(performs load operation).Declaration
Parameters
expected
The value expected to be found in the receiver.
desired
The value to store in the receiver if it is as expected.
order
The memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
loadOrder
The memory synchronization ordering for the load operation if the comparison fails. Cannot specify stronger ordering than
order
.Return Value
The value actually stored in the receiver. If exchange succeeded, this will be equal to
expected
. -
Atomically compares the value pointed to by the receiver with the value pointed to by
expected
, and if those are equal, replaces the former withdesired
(performs read-modify-write operation). Otherwise, loads the actual value pointed to by the receiver into*expected
(performs load operation).This form of compare-and-exchange is allowed to fail spuriously, that is, act as if
*current != *expected
even if they are equal. When a compare-and-exchange is in a loop, this version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.Declaration
Parameters
expected
The value expected to be found in the receiver.
desired
The value to store in the receiver if it is as expected.
order
The memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
loadOrder
The memory synchronization ordering for the load operation if the comparison fails. Cannot specify stronger ordering than
order
.Return Value
The result of the comparison:
true
if current value was equal to*expected
,false
otherwise. -
Atomically compares the value pointed to by the receiver with the value pointed to by
expected
, and if those are equal, replaces the former withdesired
(performs read-modify-write operation). Otherwise, loads the actual value pointed to by the receiver into*expected
(performs load operation).This form of compare-and-exchange is allowed to fail spuriously, that is, act as if
*current != *expected
even if they are equal. When a compare-and-exchange is in a loop, this version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.Declaration
Parameters
expected
The value expected to be found in the receiver.
desired
The value to store in the receiver if it is as expected.
order
The memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
loadOrder
The memory synchronization ordering for the load operation if the comparison fails. Cannot specify stronger ordering than
order
.Return Value
The value actually stored in the receiver. If exchange succeeded, this will be equal to
expected
. -
Atomically replaces the value pointed by the receiver with the result of bitwise
AND
between the old value of the receiver andvalue
, and returns the value the receiver held previously. The operation is read-modify-write operation.Declaration
Parameters
value
The value to bitwise
AND
to the value stored in the receiver.order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Atomically replaces the value pointed by the receiver with the result of bitwise
OR
between the old value of the receiver andvalue
, and returns the value the receiver held previously. The operation is read-modify-write operation.Declaration
Parameters
value
The value to bitwise
OR
to the value stored in the receiver.order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Atomically replaces the value pointed by the receiver with the result of bitwise
XOR
between the old value of the receiver andvalue
, and returns the value the receiver held previously. The operation is read-modify-write operation.Declaration
Parameters
value
The value to bitwise
XOR
to the value stored in the receiver.order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.