Contents

WordPair

A pair of two word sized UInts.

Declaration

@frozen struct WordPair

Overview

This type’s primary purpose is to be used in double wide atomic operations. On platforms that support it, atomic operations on WordPair are done in a single operation for two words. Users can use this type as itself when used on Atomic, or it could be used as an intermediate step for custom AtomicRepresentable types that are also double wide.

let atomicPair = Atomic<WordPair>(WordPair(first: 0, second: 0))
atomicPair.store(WordPair(first: someVersion, second: .max), ordering: .relaxed)

When used as an intermediate step for custom AtomicRepresentable types, it is critical that their AtomicRepresentation be equal to WordPair.AtomicRepresentation.

struct GridPoint {
  var x: Int
  var y: Int
}

extension GridPoint: AtomicRepresentable {
  typealias AtomicRepresentation = WordPair.AtomicRepresentation

  ...
}

Topics

Initializers

Instance Properties

Default Implementations

See Also

Atomic Values