forked from apple/swift-atomics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtomicOptional.swift
25 lines (23 loc) · 1.09 KB
/
AtomicOptional.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//===----------------------------------------------------------------------===//
//
// 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
}