Files
swift-atomics/Sources/Atomics/AtomicOptional.swift
T
2020-10-01 16:57:36 -07:00

26 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Atomics open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
/// An atomic value that also supports atomic operations when wrapped
/// in an `Optional`. Atomic optional wrappable types come with a
/// standalone atomic representation for their optional-wrapped
/// variants.
public protocol AtomicOptionalWrappable: AtomicValue {
/// The atomic storage representation for `Optional<Self>`.
associatedtype AtomicOptionalRepresentation: AtomicStorage
where AtomicOptionalRepresentation.Value == Self?
}
extension Optional: AtomicValue where Wrapped: AtomicOptionalWrappable {
public typealias AtomicRepresentation = Wrapped.AtomicOptionalRepresentation
}