Skip to content

Commit a2f88f6

Browse files
committed
[Concurrency] Mark all of the custom global excecutor API as SPI for now.
Also expose CooperativeExecutor as public (but SPI). rdar://151147606
1 parent e473977 commit a2f88f6

25 files changed

+217
-4
lines changed

stdlib/public/Concurrency/CFExecutor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum CoreFoundation {
4343

4444
// .. Main Executor ............................................................
4545

46+
@_spi(CustomDefaultExecutors)
4647
@available(StdlibDeploymentTarget 6.2, *)
4748
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
4849

@@ -58,6 +59,7 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
5859

5960
// .. Task Executor ............................................................
6061

62+
@_spi(CustomDefaultExecutors)
6163
@available(StdlibDeploymentTarget 6.2, *)
6264
public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
6365
@unchecked Sendable {

stdlib/public/Concurrency/Clock.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public protocol Clock<Duration>: Sendable {
4343
#endif
4444

4545
/// The traits associated with this clock instance.
46+
@_spi(CustomDefaultExecutors)
4647
@available(StdlibDeploymentTarget 6.2, *)
4748
var traits: ClockTraits { get }
4849

@@ -59,6 +60,7 @@ public protocol Clock<Duration>: Sendable {
5960
///
6061
/// Returns: A `Swift.Duration` representing the equivalent duration, or
6162
/// `nil` if this function is not supported.
63+
@_spi(CustomDefaultExecutors)
6264
@available(StdlibDeploymentTarget 6.2, *)
6365
func convert(from duration: Duration) -> Swift.Duration?
6466

@@ -70,6 +72,7 @@ public protocol Clock<Duration>: Sendable {
7072
///
7173
/// Returns: A `Duration` representing the equivalent duration, or
7274
/// `nil` if this function is not supported.
75+
@_spi(CustomDefaultExecutors)
7376
@available(StdlibDeploymentTarget 6.2, *)
7477
func convert(from duration: Swift.Duration) -> Duration?
7578

@@ -82,6 +85,7 @@ public protocol Clock<Duration>: Sendable {
8285
///
8386
/// Returns: An `Instant` representing the equivalent instant, or
8487
/// `nil` if this function is not supported.
88+
@_spi(CustomDefaultExecutors)
8589
@available(StdlibDeploymentTarget 6.2, *)
8690
func convert<OtherClock: Clock>(instant: OtherClock.Instant,
8791
from clock: OtherClock) -> Instant?
@@ -140,17 +144,22 @@ extension Clock {
140144
}
141145
}
142146

143-
@available(StdlibDeploymentTarget 6.2, *)
144147
extension Clock {
145148
// For compatibility, return `nil` if this is not implemented
149+
@_spi(CustomDefaultExecutors)
150+
@available(StdlibDeploymentTarget 6.2, *)
146151
public func convert(from duration: Duration) -> Swift.Duration? {
147152
return nil
148153
}
149154

155+
@_spi(CustomDefaultExecutors)
156+
@available(StdlibDeploymentTarget 6.2, *)
150157
public func convert(from duration: Swift.Duration) -> Duration? {
151158
return nil
152159
}
153160

161+
@_spi(CustomDefaultExecutors)
162+
@available(StdlibDeploymentTarget 6.2, *)
154163
public func convert<OtherClock: Clock>(instant: OtherClock.Instant,
155164
from clock: OtherClock) -> Instant? {
156165
let ourNow = now
@@ -171,8 +180,9 @@ extension Clock {
171180
}
172181
}
173182

174-
@available(StdlibDeploymentTarget 6.2, *)
175183
extension Clock where Duration == Swift.Duration {
184+
@_spi(CustomDefaultExecutors)
185+
@available(StdlibDeploymentTarget 6.2, *)
176186
public func convert(from duration: Duration) -> Duration? {
177187
return duration
178188
}
@@ -207,6 +217,7 @@ extension Clock {
207217
/// clocks best matches the clock that the user is trying to specify a
208218
/// time or delay in. Executors are expected to do this on a best effort
209219
/// basis.
220+
@_spi(CustomDefaultExecutors)
210221
@available(StdlibDeploymentTarget 6.2, *)
211222
public struct ClockTraits: OptionSet {
212223
public let rawValue: UInt32
@@ -228,6 +239,7 @@ public struct ClockTraits: OptionSet {
228239
@available(StdlibDeploymentTarget 6.2, *)
229240
extension Clock {
230241
/// The traits associated with this clock instance.
242+
@_spi(CustomDefaultExecutors)
231243
@available(StdlibDeploymentTarget 6.2, *)
232244
public var traits: ClockTraits {
233245
return []

stdlib/public/Concurrency/ContinuousClock.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ extension ContinuousClock: Clock {
101101
}
102102

103103
/// The continuous clock is continuous and monotonic
104+
@_spi(CustomDefaultExecutors)
104105
@available(StdlibDeploymentTarget 6.2, *)
105106
public var traits: ClockTraits {
106107
return [.continuous, .monotonic]

stdlib/public/Concurrency/CooperativeExecutor.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ extension ExecutorJob {
9999

100100
/// A co-operative executor that can be used as the main executor or as a
101101
/// task executor.
102+
@_spi(CustomDefaultExecutors)
102103
@available(StdlibDeploymentTarget 6.2, *)
103-
class CooperativeExecutor: Executor, @unchecked Sendable {
104+
public class CooperativeExecutor: Executor, @unchecked Sendable {
104105
var runQueue: PriorityQueue<UnownedJob>
105106
var waitQueue: PriorityQueue<UnownedJob>
106107
var shouldStop: Bool = false
@@ -179,6 +180,7 @@ class CooperativeExecutor: Executor, @unchecked Sendable {
179180
public var asSchedulable: any SchedulableExecutor { self }
180181
}
181182

183+
@_spi(CustomDefaultExecutors)
182184
@available(StdlibDeploymentTarget 6.2, *)
183185
extension CooperativeExecutor: SchedulableExecutor {
184186
var currentTime: Timestamp {
@@ -202,6 +204,7 @@ extension CooperativeExecutor: SchedulableExecutor {
202204
}
203205
}
204206

207+
@_spi(CustomDefaultExecutors)
205208
@available(StdlibDeploymentTarget 6.2, *)
206209
extension CooperativeExecutor: RunLoopExecutor {
207210
public func run() throws {
@@ -249,12 +252,15 @@ extension CooperativeExecutor: RunLoopExecutor {
249252
}
250253
}
251254

255+
@_spi(CustomDefaultExecutors)
252256
@available(StdlibDeploymentTarget 6.2, *)
253257
extension CooperativeExecutor: SerialExecutor {}
254258

259+
@_spi(CustomDefaultExecutors)
255260
@available(StdlibDeploymentTarget 6.2, *)
256261
extension CooperativeExecutor: TaskExecutor {}
257262

263+
@_spi(CustomDefaultExecutors)
258264
@available(StdlibDeploymentTarget 6.2, *)
259265
extension CooperativeExecutor: MainExecutor {}
260266

stdlib/public/Concurrency/DispatchExecutor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Swift
2323

2424
// .. Main Executor ............................................................
2525

26+
@_spi(CustomDefaultExecutors)
2627
@available(StdlibDeploymentTarget 6.2, *)
2728
public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable {
2829
var threaded = false
@@ -43,6 +44,7 @@ public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable {
4344
}
4445
}
4546

47+
@_spi(CustomDefaultExecutors)
4648
@available(StdlibDeploymentTarget 6.2, *)
4749
extension DispatchMainExecutor: SerialExecutor {
4850

@@ -57,6 +59,7 @@ extension DispatchMainExecutor: SerialExecutor {
5759
}
5860
}
5961

62+
@_spi(CustomDefaultExecutors)
6063
@available(StdlibDeploymentTarget 6.2, *)
6164
extension DispatchMainExecutor: SchedulableExecutor {
6265
public var asSchedulable: SchedulableExecutor? {
@@ -85,11 +88,13 @@ extension DispatchMainExecutor: SchedulableExecutor {
8588
}
8689
}
8790

91+
@_spi(CustomDefaultExecutors)
8892
@available(StdlibDeploymentTarget 6.2, *)
8993
extension DispatchMainExecutor: MainExecutor {}
9094

9195
// .. Task Executor ............................................................
9296

97+
@_spi(CustomDefaultExecutors)
9398
@available(StdlibDeploymentTarget 6.2, *)
9499
public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor,
95100
@unchecked Sendable {
@@ -201,10 +206,12 @@ extension DispatchExecutorProtocol {
201206

202207
}
203208

209+
@_spi(CustomDefaultExecutors)
204210
@available(StdlibDeploymentTarget 6.2, *)
205211
extension DispatchGlobalTaskExecutor: DispatchExecutorProtocol {
206212
}
207213

214+
@_spi(CustomDefaultExecutors)
208215
@available(StdlibDeploymentTarget 6.2, *)
209216
extension DispatchMainExecutor: DispatchExecutorProtocol {
210217
}

stdlib/public/Concurrency/DummyExecutor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Swift
1414

1515
// .. Main Executor ............................................................
1616

17+
@_spi(CustomDefaultExecutors)
1718
@available(SwiftStdlib 6.2, *)
1819
public final class DummyMainExecutor: MainExecutor, @unchecked Sendable {
1920
public init() {}
@@ -45,6 +46,7 @@ public final class DummyMainExecutor: MainExecutor, @unchecked Sendable {
4546

4647
// .. Task Executor ............................................................
4748

49+
@_spi(CustomDefaultExecutors)
4850
@available(SwiftStdlib 6.2, *)
4951
public final class DummyTaskExecutor: TaskExecutor, @unchecked Sendable {
5052
public init() {}

0 commit comments

Comments
 (0)