Atomic
public enum Atomic
-
Generic memory order-dependent fence synchronization primitive.
Establishes memory synchronization ordering of non-atomic and relaxed atomic accesses, as instructed by
order
, without an associated atomic operation.For example, all non-atomic and relaxed atomic stores that happen before a memory_order_release fence in thread A will be synchronized with non-atomic and relaxed atomic loads from the same locations made in thread B after an memory_order_acquire fence.
Declaration
Swift
public static func threadFence(order: AtomicMemoryOrder = .seqcst)
Parameters
order
the memory ordering executed by this fence
-
Indicates to the hardware that the current thread is performing a task, for example a spinlock, that can be swapped out. Hardware can use this hint to suspend and resume threads.
Declaration
Swift
public static func hardwarePause()
-
Causes the calling thread to relinquish the CPU. The thread is moved to the end of the queue for its static priority and a new thread gets to run.
Declaration
Swift
public static func preemptionYield(_ timeout: UInt64)
Parameters
timeout
The time interval to suppress this thread’s priority for, in milliseconds.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicBoolPointer, to initialValue: Bool)
-
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 static func load(_ ptr: AtomicBoolPointer, order: AtomicLoadMemoryOrder = .seqcst) -> Bool
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 static func store(_ ptr: AtomicBoolPointer, _ desired: Bool, 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
Swift
public static func exchange(_ ptr: AtomicBoolPointer, _ desired: Bool, order: AtomicMemoryOrder = .seqcst) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicBoolPointer, _ expected: UnsafeMutablePointer<Bool>, _ desired: Bool, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicBoolPointer, _ expected: Bool, _ desired: Bool, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicBoolPointer, _ expected: UnsafeMutablePointer<Bool>, _ desired: Bool, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicBoolPointer, _ expected: Bool, _ desired: Bool, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicBoolPointer, _ value: Bool, order: AtomicMemoryOrder = .seqcst) -> Bool
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicBoolPointer, _ value: Bool, order: AtomicMemoryOrder = .seqcst) -> Bool
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicBoolPointer, _ value: Bool, order: AtomicMemoryOrder = .seqcst) -> Bool
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.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicIntPointer, to initialValue: Int)
-
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 static func load(_ ptr: AtomicIntPointer, order: AtomicLoadMemoryOrder = .seqcst) -> Int
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 static func store(_ ptr: AtomicIntPointer, _ desired: Int, 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
Swift
public static func exchange(_ ptr: AtomicIntPointer, _ desired: Int, order: AtomicMemoryOrder = .seqcst) -> Int
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicIntPointer, _ expected: UnsafeMutablePointer<Int>, _ desired: Int, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicIntPointer, _ expected: Int, _ desired: Int, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicIntPointer, _ expected: UnsafeMutablePointer<Int>, _ desired: Int, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicIntPointer, _ expected: Int, _ desired: Int, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicIntPointer, _ value: Int, order: AtomicMemoryOrder = .seqcst) -> Int
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicIntPointer, _ value: Int, order: AtomicMemoryOrder = .seqcst) -> Int
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicIntPointer, _ value: Int, order: AtomicMemoryOrder = .seqcst) -> Int
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicIntPointer, _ value: Int, order: AtomicMemoryOrder = .seqcst) -> Int
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicIntPointer, _ value: Int, order: AtomicMemoryOrder = .seqcst) -> Int
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicInt8Pointer, to initialValue: Int8)
-
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 static func load(_ ptr: AtomicInt8Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> Int8
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 static func store(_ ptr: AtomicInt8Pointer, _ desired: Int8, 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
Swift
public static func exchange(_ ptr: AtomicInt8Pointer, _ desired: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt8Pointer, _ expected: UnsafeMutablePointer<Int8>, _ desired: Int8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt8Pointer, _ expected: Int8, _ desired: Int8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int8
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt8Pointer, _ expected: UnsafeMutablePointer<Int8>, _ desired: Int8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt8Pointer, _ expected: Int8, _ desired: Int8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int8
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicInt8Pointer, _ value: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicInt8Pointer, _ value: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicInt8Pointer, _ value: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicInt8Pointer, _ value: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicInt8Pointer, _ value: Int8, order: AtomicMemoryOrder = .seqcst) -> Int8
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicInt16Pointer, to initialValue: Int16)
-
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 static func load(_ ptr: AtomicInt16Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> Int16
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 static func store(_ ptr: AtomicInt16Pointer, _ desired: Int16, 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
Swift
public static func exchange(_ ptr: AtomicInt16Pointer, _ desired: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt16Pointer, _ expected: UnsafeMutablePointer<Int16>, _ desired: Int16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt16Pointer, _ expected: Int16, _ desired: Int16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int16
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt16Pointer, _ expected: UnsafeMutablePointer<Int16>, _ desired: Int16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt16Pointer, _ expected: Int16, _ desired: Int16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int16
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicInt16Pointer, _ value: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicInt16Pointer, _ value: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicInt16Pointer, _ value: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicInt16Pointer, _ value: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicInt16Pointer, _ value: Int16, order: AtomicMemoryOrder = .seqcst) -> Int16
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicInt32Pointer, to initialValue: Int32)
-
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 static func load(_ ptr: AtomicInt32Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> Int32
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 static func store(_ ptr: AtomicInt32Pointer, _ desired: Int32, 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
Swift
public static func exchange(_ ptr: AtomicInt32Pointer, _ desired: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt32Pointer, _ expected: UnsafeMutablePointer<Int32>, _ desired: Int32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt32Pointer, _ expected: Int32, _ desired: Int32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int32
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt32Pointer, _ expected: UnsafeMutablePointer<Int32>, _ desired: Int32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt32Pointer, _ expected: Int32, _ desired: Int32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int32
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicInt32Pointer, _ value: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicInt32Pointer, _ value: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicInt32Pointer, _ value: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicInt32Pointer, _ value: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicInt32Pointer, _ value: Int32, order: AtomicMemoryOrder = .seqcst) -> Int32
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicInt64Pointer, to initialValue: Int64)
-
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 static func load(_ ptr: AtomicInt64Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> Int64
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 static func store(_ ptr: AtomicInt64Pointer, _ desired: Int64, 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
Swift
public static func exchange(_ ptr: AtomicInt64Pointer, _ desired: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt64Pointer, _ expected: UnsafeMutablePointer<Int64>, _ desired: Int64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicInt64Pointer, _ expected: Int64, _ desired: Int64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int64
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt64Pointer, _ expected: UnsafeMutablePointer<Int64>, _ desired: Int64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicInt64Pointer, _ expected: Int64, _ desired: Int64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Int64
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicInt64Pointer, _ value: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicInt64Pointer, _ value: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicInt64Pointer, _ value: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicInt64Pointer, _ value: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicInt64Pointer, _ value: Int64, order: AtomicMemoryOrder = .seqcst) -> Int64
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicUIntPointer, to initialValue: UInt)
-
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 static func load(_ ptr: AtomicUIntPointer, order: AtomicLoadMemoryOrder = .seqcst) -> UInt
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 static func store(_ ptr: AtomicUIntPointer, _ desired: UInt, 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
Swift
public static func exchange(_ ptr: AtomicUIntPointer, _ desired: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUIntPointer, _ expected: UnsafeMutablePointer<UInt>, _ desired: UInt, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUIntPointer, _ expected: UInt, _ desired: UInt, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUIntPointer, _ expected: UnsafeMutablePointer<UInt>, _ desired: UInt, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUIntPointer, _ expected: UInt, _ desired: UInt, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicUIntPointer, _ value: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicUIntPointer, _ value: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicUIntPointer, _ value: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicUIntPointer, _ value: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicUIntPointer, _ value: UInt, order: AtomicMemoryOrder = .seqcst) -> UInt
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicUInt8Pointer, to initialValue: UInt8)
-
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 static func load(_ ptr: AtomicUInt8Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> UInt8
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 static func store(_ ptr: AtomicUInt8Pointer, _ desired: UInt8, 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
Swift
public static func exchange(_ ptr: AtomicUInt8Pointer, _ desired: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt8Pointer, _ expected: UnsafeMutablePointer<UInt8>, _ desired: UInt8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt8Pointer, _ expected: UInt8, _ desired: UInt8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt8
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt8Pointer, _ expected: UnsafeMutablePointer<UInt8>, _ desired: UInt8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt8Pointer, _ expected: UInt8, _ desired: UInt8, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt8
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicUInt8Pointer, _ value: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicUInt8Pointer, _ value: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicUInt8Pointer, _ value: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicUInt8Pointer, _ value: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicUInt8Pointer, _ value: UInt8, order: AtomicMemoryOrder = .seqcst) -> UInt8
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicUInt16Pointer, to initialValue: UInt16)
-
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 static func load(_ ptr: AtomicUInt16Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> UInt16
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 static func store(_ ptr: AtomicUInt16Pointer, _ desired: UInt16, 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
Swift
public static func exchange(_ ptr: AtomicUInt16Pointer, _ desired: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt16Pointer, _ expected: UnsafeMutablePointer<UInt16>, _ desired: UInt16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt16Pointer, _ expected: UInt16, _ desired: UInt16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt16
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt16Pointer, _ expected: UnsafeMutablePointer<UInt16>, _ desired: UInt16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt16Pointer, _ expected: UInt16, _ desired: UInt16, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt16
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicUInt16Pointer, _ value: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicUInt16Pointer, _ value: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicUInt16Pointer, _ value: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicUInt16Pointer, _ value: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicUInt16Pointer, _ value: UInt16, order: AtomicMemoryOrder = .seqcst) -> UInt16
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicUInt32Pointer, to initialValue: UInt32)
-
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 static func load(_ ptr: AtomicUInt32Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> UInt32
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 static func store(_ ptr: AtomicUInt32Pointer, _ desired: UInt32, 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
Swift
public static func exchange(_ ptr: AtomicUInt32Pointer, _ desired: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt32Pointer, _ expected: UnsafeMutablePointer<UInt32>, _ desired: UInt32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt32Pointer, _ expected: UInt32, _ desired: UInt32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt32
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt32Pointer, _ expected: UnsafeMutablePointer<UInt32>, _ desired: UInt32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt32Pointer, _ expected: UInt32, _ desired: UInt32, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt32
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicUInt32Pointer, _ value: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicUInt32Pointer, _ value: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicUInt32Pointer, _ value: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicUInt32Pointer, _ value: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicUInt32Pointer, _ value: UInt32, order: AtomicMemoryOrder = .seqcst) -> UInt32
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.
-
Declaration
Swift
public static func initialize(_ ptr: AtomicUInt64Pointer, to initialValue: UInt64)
-
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 static func load(_ ptr: AtomicUInt64Pointer, order: AtomicLoadMemoryOrder = .seqcst) -> UInt64
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 static func store(_ ptr: AtomicUInt64Pointer, _ desired: UInt64, 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
Swift
public static func exchange(_ ptr: AtomicUInt64Pointer, _ desired: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt64Pointer, _ expected: UnsafeMutablePointer<UInt64>, _ desired: UInt64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchange( _ ptr: AtomicUInt64Pointer, _ expected: UInt64, _ desired: UInt64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt64
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt64Pointer, _ expected: UnsafeMutablePointer<UInt64>, _ desired: UInt64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> Bool
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
Swift
@discardableResult public static func compareExchangeWeak( _ ptr: AtomicUInt64Pointer, _ expected: UInt64, _ desired: UInt64, order: AtomicMemoryOrder = .seqcst, loadOrder: AtomicLoadMemoryOrder? = nil ) -> UInt64
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
Swift
@discardableResult public static func fetchAnd(_ ptr: AtomicUInt64Pointer, _ value: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
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
Swift
@discardableResult public static func fetchOr(_ ptr: AtomicUInt64Pointer, _ value: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
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
Swift
@discardableResult public static func fetchXor(_ ptr: AtomicUInt64Pointer, _ value: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
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.
-
Atomically replaces the value pointed by the receiver with the result of addition of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchAdd(_ ptr: AtomicUInt64Pointer, _ value: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
Parameters
value
The value to add 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 subtraction of
value
to the old value of the receiver, and returns the value the receiver held previously. The operation is read-modify-write operation.For signed integer types, arithmetic is defined to use two’s complement representation. There are no undefined results. For pointer types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
Declaration
Swift
@discardableResult public static func fetchSub(_ ptr: AtomicUInt64Pointer, _ value: UInt64, order: AtomicMemoryOrder = .seqcst) -> UInt64
Parameters
value
The value to subtract from the value stored in the receiver.
order
The memory synchronization ordering for this operation.
Return Value
The value previously stored in the receiver.