@@ -21,37 +21,37 @@ import Swift
21
21
extension ExecutorJob {
22
22
fileprivate var cooperativeExecutorTimestampIsIndirect : Bool {
23
23
return MemoryLayout < ( Int , Int ) > . size
24
- < MemoryLayout < _CooperativeExecutor . Timestamp > . size
24
+ < MemoryLayout < CooperativeExecutor . Timestamp > . size
25
25
}
26
26
27
- fileprivate var cooperativeExecutorTimestampPointer : UnsafeMutablePointer < _CooperativeExecutor . Timestamp > {
27
+ fileprivate var cooperativeExecutorTimestampPointer : UnsafeMutablePointer < CooperativeExecutor . Timestamp > {
28
28
get {
29
29
assert ( cooperativeExecutorTimestampIsIndirect)
30
- return unsafe _withUnsafeExecutorPrivateData {
31
- unsafe $0. withMemoryRebound ( to: UnsafeMutablePointer< _CooperativeExecutor . Timestamp> . self ) {
30
+ return unsafe withUnsafeExecutorPrivateData {
31
+ unsafe $0. withMemoryRebound ( to: UnsafeMutablePointer< CooperativeExecutor . Timestamp> . self ) {
32
32
return unsafe $0[ 0 ]
33
33
}
34
34
}
35
35
}
36
36
set {
37
37
assert ( cooperativeExecutorTimestampIsIndirect)
38
- unsafe _withUnsafeExecutorPrivateData {
39
- unsafe $0. withMemoryRebound ( to: UnsafeMutablePointer< _CooperativeExecutor . Timestamp> . self ) {
38
+ unsafe withUnsafeExecutorPrivateData {
39
+ unsafe $0. withMemoryRebound ( to: UnsafeMutablePointer< CooperativeExecutor . Timestamp> . self ) {
40
40
unsafe $0[ 0 ] = newValue
41
41
}
42
42
}
43
43
}
44
44
}
45
45
46
- fileprivate var cooperativeExecutorTimestamp : _CooperativeExecutor . Timestamp {
46
+ fileprivate var cooperativeExecutorTimestamp : CooperativeExecutor . Timestamp {
47
47
get {
48
48
if cooperativeExecutorTimestampIsIndirect {
49
49
let ptr = unsafe cooperativeExecutorTimestampPointer
50
50
return unsafe ptr. pointee
51
51
} else {
52
- return unsafe _withUnsafeExecutorPrivateData {
52
+ return unsafe withUnsafeExecutorPrivateData {
53
53
return unsafe $0. assumingMemoryBound (
54
- to: _CooperativeExecutor . Timestamp. self
54
+ to: CooperativeExecutor . Timestamp. self
55
55
) [ 0 ]
56
56
}
57
57
}
@@ -61,8 +61,8 @@ extension ExecutorJob {
61
61
let ptr = unsafe cooperativeExecutorTimestampPointer
62
62
unsafe ptr. pointee = newValue
63
63
} else {
64
- unsafe _withUnsafeExecutorPrivateData {
65
- unsafe $0. withMemoryRebound ( to: _CooperativeExecutor . Timestamp. self) {
64
+ unsafe withUnsafeExecutorPrivateData {
65
+ unsafe $0. withMemoryRebound ( to: CooperativeExecutor . Timestamp. self) {
66
66
unsafe $0[ 0 ] = newValue
67
67
}
68
68
}
@@ -73,10 +73,10 @@ extension ExecutorJob {
73
73
fileprivate mutating func setupCooperativeExecutorTimestamp( ) {
74
74
// If a Timestamp won't fit, allocate
75
75
if cooperativeExecutorTimestampIsIndirect {
76
- let ptr : UnsafeMutablePointer < _CooperativeExecutor . Timestamp >
76
+ let ptr : UnsafeMutablePointer < CooperativeExecutor . Timestamp >
77
77
// Try to use the task allocator if it has one
78
78
if let allocator {
79
- unsafe ptr = allocator. allocate ( as: _CooperativeExecutor . Timestamp. self)
79
+ unsafe ptr = allocator. allocate ( as: CooperativeExecutor . Timestamp. self)
80
80
} else {
81
81
unsafe ptr = . allocate( capacity: 1 )
82
82
}
@@ -100,7 +100,7 @@ extension ExecutorJob {
100
100
/// A co-operative executor that can be used as the main executor or as a
101
101
/// task executor.
102
102
@available ( SwiftStdlib 6 . 2 , * )
103
- class _CooperativeExecutor : Executor , @unchecked Sendable {
103
+ class CooperativeExecutor : Executor , @unchecked Sendable {
104
104
var runQueue : PriorityQueue < UnownedJob >
105
105
var waitQueue : PriorityQueue < UnownedJob >
106
106
var shouldStop : Bool = false
@@ -174,13 +174,13 @@ class _CooperativeExecutor: Executor, @unchecked Sendable {
174
174
runQueue. push ( UnownedJob ( job) )
175
175
}
176
176
177
- public var _isMainExecutor : Bool { true }
177
+ public var isMainExecutor : Bool { true }
178
178
179
- public var _asSchedulable : any _SchedulableExecutor { self }
179
+ public var asSchedulable : any SchedulableExecutor { self }
180
180
}
181
181
182
182
@available ( SwiftStdlib 6 . 2 , * )
183
- extension _CooperativeExecutor : _SchedulableExecutor {
183
+ extension CooperativeExecutor : SchedulableExecutor {
184
184
var currentTime : Timestamp {
185
185
var now : Timestamp = . zero
186
186
unsafe _getTime ( seconds: & now. seconds,
@@ -189,11 +189,11 @@ extension _CooperativeExecutor: _SchedulableExecutor {
189
189
return now
190
190
}
191
191
192
- public func _enqueue < C: Clock > ( _ job: consuming ExecutorJob ,
193
- after delay: C . Duration ,
194
- tolerance: C . Duration ? = nil ,
195
- clock: C ) {
196
- let duration = Duration ( from: clock. _convert ( from: delay) !)
192
+ public func enqueue < C: Clock > ( _ job: consuming ExecutorJob ,
193
+ after delay: C . Duration ,
194
+ tolerance: C . Duration ? = nil ,
195
+ clock: C ) {
196
+ let duration = Duration ( from: clock. convert ( from: delay) !)
197
197
let deadline = self . currentTime + duration
198
198
199
199
job. setupCooperativeExecutorTimestamp ( )
@@ -203,12 +203,12 @@ extension _CooperativeExecutor: _SchedulableExecutor {
203
203
}
204
204
205
205
@available ( SwiftStdlib 6 . 2 , * )
206
- extension _CooperativeExecutor : _RunLoopExecutor {
207
- public func _run ( ) throws {
208
- try _runUntil { false }
206
+ extension CooperativeExecutor : RunLoopExecutor {
207
+ public func run ( ) throws {
208
+ try runUntil { false }
209
209
}
210
210
211
- public func _runUntil ( _ condition: ( ) -> Bool ) throws {
211
+ public func runUntil ( _ condition: ( ) -> Bool ) throws {
212
212
shouldStop = false
213
213
while !shouldStop && !condition( ) {
214
214
// Process the timer queue
@@ -244,18 +244,18 @@ extension _CooperativeExecutor: _RunLoopExecutor {
244
244
}
245
245
}
246
246
247
- public func _stop ( ) {
247
+ public func stop ( ) {
248
248
shouldStop = true
249
249
}
250
250
}
251
251
252
252
@available( SwiftStdlib 6.2 , * )
253
- extension _CooperativeExecutor : SerialExecutor { }
253
+ extension CooperativeExecutor : SerialExecutor { }
254
254
255
255
@available( SwiftStdlib 6.2 , * )
256
- extension _CooperativeExecutor : TaskExecutor { }
256
+ extension CooperativeExecutor : TaskExecutor { }
257
257
258
258
@available( SwiftStdlib 6.2 , * )
259
- extension _CooperativeExecutor : _MainExecutor { }
259
+ extension CooperativeExecutor : MainExecutor { }
260
260
261
261
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
0 commit comments