Instance Methodswift-nio 2.72.0NIOConcurrencyHelpers
exchange(with:)
Atomically exchanges value
for the current value of this object.
This declaration is deprecated: please use ManagedAtomic from https://github.com/apple/swift-atomics instead
func exchange(with value: T) -> T
Parameters
- value
The new value to set this object to.
Returns
The value previously held by this object.
This implementation uses a relaxed memory ordering. This guarantees nothing more than that this operation is atomic: there is no guarantee that any other event will be ordered before or after this one.
Other members in extension
Type members
Show obsolete interfaces (1)
Hide obsolete interfaces
init(value: T
) Create an atomic object with
value
.
Instance members
Show obsolete interfaces (5)
Hide obsolete interfaces
func add(T
) -> T Atomically adds
rhs
to this object.func compareAndExchange(expected: T, desired: T
) -> Bool Atomically compares the value against
expected
and, if they are equal, replaces the value withdesired
.func load(
) -> T Atomically loads and returns the value of this object.
func store(T
) Atomically replaces the value of this object with
value
.func sub(T
) -> T Atomically subtracts
rhs
from this object.