You are viewing documentation for a previous version of this software.

Switch to the latest stable version.

Atomic


CLASS

Atomic

Swift
1public class Atomic<T>

Wrapper for a value protected by an NSLock

Properties

value

Swift
1public var value: T

The current value. Read-only. To update the underlying value, use mutate.

Methods

init(_:)

Swift
1public init(_ value: T)

Designated initializer

  • Parameter value: The value to begin with.

Parameters

NameDescription
valueThe value to begin with.

mutate(block:)

Swift
1public func mutate<U>(block: (inout T) -> U) -> U

Mutates the underlying value within a lock.

  • Parameter block: The block to execute to mutate the value.

  • Returns: The value returned by the block.

Parameters

NameDescription
blockThe block to execute to mutate the value.
Feedback

Edit on GitHub

Forums