Skip to content

Commit a632118

Browse files
committed
Sink ConcurrentValue into the standard library as a marker protocol
By making ConcurrentValue a marker protocol, it no longer has any ABI impact whatsoever. Sink it down into the Standard Library so it's easier to use, even from code that isn't building with concurrency enabled.
1 parent 27e0b12 commit a632118

File tree

8 files changed

+13
-34
lines changed

8 files changed

+13
-34
lines changed

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
971971
M = getLoadedModule(Id_Differentiation);
972972
break;
973973
case KnownProtocolKind::Actor:
974-
case KnownProtocolKind::ConcurrentValue:
975974
case KnownProtocolKind::AsyncSequence:
976975
case KnownProtocolKind::AsyncIteratorProtocol:
977976
M = getLoadedModule(Id_Concurrency);

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
3737
Actor.cpp
3838
Actor.swift
3939
CheckedContinuation.swift
40-
ConcurrentValue.swift
4140
GlobalExecutor.cpp
4241
AsyncIteratorProtocol.swift
4342
AsyncSequence.swift

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(SWIFTLIB_ESSENTIAL
4545
CollectionAlgorithms.swift
4646
Comparable.swift
4747
CompilerProtocols.swift
48+
ConcurrentValue.swift
4849
ContiguousArray.swift
4950
ContiguouslyStored.swift
5051
ClosedRange.swift

stdlib/public/Concurrency/ConcurrentValue.swift renamed to stdlib/public/core/ConcurrentValue.swift

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Swift
1414

1515
/// The ConcurrentValue protocol indicates that value of the given type can
1616
/// be safely used in concurrent code.
17-
public protocol ConcurrentValue { }
17+
@_marker public protocol ConcurrentValue { }
1818

1919
extension Array: ConcurrentValue where Element: ConcurrentValue { }
2020
extension ArraySlice: ConcurrentValue where Element: ConcurrentValue { }
@@ -115,40 +115,13 @@ extension Mirror: ConcurrentValue { }
115115
extension Mirror.AncestorRepresentation: ConcurrentValue { }
116116
extension Mirror.DisplayStyle: ConcurrentValue { }
117117

118-
// FIXME: Float16 when available
119-
extension Float: ConcurrentValue { }
120-
extension Double: ConcurrentValue { }
121-
// FIXME: Float80 when available
122-
123-
// FIXME: hacks to enumerate integer types, and ".Words", and "SIMDnStorage"
124-
extension UInt8: ConcurrentValue { }
125-
extension Int8: ConcurrentValue { }
126-
extension UInt16: ConcurrentValue { }
127-
extension Int16: ConcurrentValue { }
128-
extension UInt32: ConcurrentValue { }
129-
extension Int32: ConcurrentValue { }
130-
extension UInt64: ConcurrentValue { }
131-
extension Int64: ConcurrentValue { }
132-
extension UInt: ConcurrentValue { }
133-
extension Int: ConcurrentValue { }
134-
135118
extension UnsafeMutableBufferPointer: ConcurrentValue { }
136119
extension UnsafeBufferPointer: ConcurrentValue { }
137120
extension UnsafeBufferPointer.Iterator: ConcurrentValue { }
138121
extension UnsafeMutableRawBufferPointer: ConcurrentValue { }
139122
extension UnsafeRawBufferPointer: ConcurrentValue { }
140123
extension UnsafeRawBufferPointer.Iterator: ConcurrentValue { }
141124

142-
extension SIMDMask: ConcurrentValue where Storage: ConcurrentValue { }
143-
// FIXME: enumerate SIMD types
144-
extension SIMD2: ConcurrentValue where Scalar: ConcurrentValue { }
145-
extension SIMD3: ConcurrentValue where Scalar: ConcurrentValue { }
146-
extension SIMD4: ConcurrentValue where Scalar: ConcurrentValue { }
147-
extension SIMD8: ConcurrentValue where Scalar: ConcurrentValue { }
148-
extension SIMD16: ConcurrentValue where Scalar: ConcurrentValue { }
149-
extension SIMD32: ConcurrentValue where Scalar: ConcurrentValue { }
150-
extension SIMD64: ConcurrentValue where Scalar: ConcurrentValue { }
151-
152125
extension PartialKeyPath: ConcurrentValue where Root: ConcurrentValue { }
153126

154127
extension FloatingPointSign: ConcurrentValue { }
@@ -158,4 +131,3 @@ extension FloatingPointRoundingRule: ConcurrentValue { }
158131
extension Optional: ConcurrentValue where Wrapped: ConcurrentValue { }
159132
extension Never: ConcurrentValue { }
160133
extension Result: ConcurrentValue where Success: ConcurrentValue, Failure: ConcurrentValue { }
161-

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,9 @@ internal struct _${Self}AnyHashableBox: _AnyHashableBox {
13431343
}
13441344
% end
13451345

1346+
${Availability(bits)}
1347+
extension ${Self} : ConcurrentValue { }
1348+
13461349
//===----------------------------------------------------------------------===//
13471350
// Deprecated operators
13481351
//===----------------------------------------------------------------------===//

stdlib/public/core/GroupInfo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
],
200200
"Misc": [
201201
"AtomicInt.swift",
202+
"ConcurrentValue.swift",
202203
"ErrorType.swift",
203204
"Identifiable.swift",
204205
"InputStream.swift",

stdlib/public/core/IntegerTypes.swift.gyb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ ${assignmentOperatorComment(x.operator, True)}
13991399

14001400
/// A type that represents the words of this integer.
14011401
@frozen
1402-
public struct Words: RandomAccessCollection {
1402+
public struct Words: RandomAccessCollection, ConcurrentValue {
14031403
public typealias Indices = Range<Int>
14041404
public typealias SubSequence = Slice<${Self}.Words>
14051405

@@ -1709,6 +1709,8 @@ ${operatorComment(x.operator, True)}
17091709
}
17101710

17111711

1712+
extension ${Self}: ConcurrentValue { }
1713+
17121714
% if signed:
17131715
// TODO: Consider removing the underscore.
17141716
/// Returns the argument and specifies that the value is not negative.

stdlib/public/core/SIMDVectorTypes.swift.gyb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ extension SIMD${n} where Scalar: BinaryFloatingPoint {
186186
}
187187
}
188188

189+
extension SIMD${n}: ConcurrentValue where Scalar: ConcurrentValue { }
190+
189191
%end
190192

191193
extension SIMD3 {
@@ -217,7 +219,7 @@ extension ${Self}: SIMDScalar {
217219
/// Storage for a vector of ${spelledNumbers[n]} integers.
218220
@frozen
219221
@_alignment(${bytes if bytes <= 16 else 16})
220-
public struct SIMD${n}Storage: SIMDStorage {
222+
public struct SIMD${n}Storage: SIMDStorage, ConcurrentValue {
221223

222224
public var _value: Builtin.Vec${n}x${BuiltinName}
223225

@@ -266,7 +268,7 @@ extension ${Self} : SIMDScalar {
266268
/// Storage for a vector of ${spelledNumbers[n]} floating-point values.
267269
@frozen
268270
@_alignment(${bytes if bytes <= 16 else 16})
269-
public struct SIMD${n}Storage: SIMDStorage {
271+
public struct SIMD${n}Storage: SIMDStorage, ConcurrentValue {
270272

271273
public var _value: Builtin.Vec${n}xFPIEEE${bits}
272274

0 commit comments

Comments
 (0)