Skip to content

Commit 28732f4

Browse files
authored
Revert "[Concurrency] Add underscore prefixes for not yet official API."
1 parent 3ec3421 commit 28732f4

32 files changed

+1179
-1179
lines changed

include/swift/AST/KnownProtocols.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ PROTOCOL(Executor)
9797
PROTOCOL(SerialExecutor)
9898
PROTOCOL(TaskExecutor)
9999
PROTOCOL(GlobalActor)
100-
PROTOCOL_(ExecutorFactory)
100+
PROTOCOL(ExecutorFactory)
101101

102102
PROTOCOL_(BridgedNSError)
103103
PROTOCOL_(BridgedStoredNSError)

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ Type SILGenModule::getConfiguredExecutorFactory() {
515515
auto &ctx = getASTContext();
516516

517517
// Look in the main module for a typealias
518-
Type factory = ctx.getNamedSwiftType(ctx.MainModule, "_DefaultExecutorFactory");
518+
Type factory = ctx.getNamedSwiftType(ctx.MainModule, "DefaultExecutorFactory");
519519

520520
// If we don't find it, fall back to _Concurrency.PlatformExecutorFactory
521521
if (!factory)
@@ -531,7 +531,7 @@ Type SILGenModule::getDefaultExecutorFactory() {
531531
if (!module)
532532
return Type();
533533

534-
return ctx.getNamedSwiftType(module, "_DefaultExecutorFactory");
534+
return ctx.getNamedSwiftType(module, "DefaultExecutorFactory");
535535
}
536536

537537
ProtocolConformance *SILGenModule::getNSErrorConformanceToError() {

stdlib/public/Concurrency/CFExecutor.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ enum CoreFoundation {
4444
// .. Main Executor ............................................................
4545

4646
@available(SwiftStdlib 6.2, *)
47-
public final class _CFMainExecutor: _DispatchMainExecutor, @unchecked Sendable {
47+
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
4848

49-
override public func _run() throws {
49+
override public func run() throws {
5050
CoreFoundation.CFRunLoopRun()
5151
}
5252

53-
override public func _stop() {
53+
override public func stop() {
5454
unsafe CoreFoundation.CFRunLoopStop(CoreFoundation.CFRunLoopGetMain())
5555
}
5656

@@ -59,8 +59,8 @@ public final class _CFMainExecutor: _DispatchMainExecutor, @unchecked Sendable {
5959
// .. Task Executor ............................................................
6060

6161
@available(SwiftStdlib 6.2, *)
62-
public final class _CFTaskExecutor: _DispatchGlobalTaskExecutor,
63-
@unchecked Sendable {
62+
public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
63+
@unchecked Sendable {
6464

6565
}
6666

stdlib/public/Concurrency/Clock.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public protocol Clock<Duration>: Sendable {
4444

4545
/// The traits associated with this clock instance.
4646
@available(SwiftStdlib 6.2, *)
47-
var _traits: _ClockTraits { get }
47+
var traits: ClockTraits { get }
4848

4949
/// Convert a Clock-specific Duration to a Swift Duration
5050
///
@@ -60,7 +60,7 @@ public protocol Clock<Duration>: Sendable {
6060
/// Returns: A `Swift.Duration` representing the equivalent duration, or
6161
/// `nil` if this function is not supported.
6262
@available(SwiftStdlib 6.2, *)
63-
func _convert(from duration: Duration) -> Swift.Duration?
63+
func convert(from duration: Duration) -> Swift.Duration?
6464

6565
/// Convert a Swift Duration to a Clock-specific Duration
6666
///
@@ -71,7 +71,7 @@ public protocol Clock<Duration>: Sendable {
7171
/// Returns: A `Duration` representing the equivalent duration, or
7272
/// `nil` if this function is not supported.
7373
@available(SwiftStdlib 6.2, *)
74-
func _convert(from duration: Swift.Duration) -> Duration?
74+
func convert(from duration: Swift.Duration) -> Duration?
7575

7676
/// Convert an `Instant` from some other clock's `Instant`
7777
///
@@ -83,8 +83,8 @@ public protocol Clock<Duration>: Sendable {
8383
/// Returns: An `Instant` representing the equivalent instant, or
8484
/// `nil` if this function is not supported.
8585
@available(SwiftStdlib 6.2, *)
86-
func _convert<OtherClock: Clock>(instant: OtherClock.Instant,
87-
from clock: OtherClock) -> Instant?
86+
func convert<OtherClock: Clock>(instant: OtherClock.Instant,
87+
from clock: OtherClock) -> Instant?
8888
}
8989

9090
@available(SwiftStdlib 5.7, *)
@@ -143,27 +143,27 @@ extension Clock {
143143
@available(SwiftStdlib 6.2, *)
144144
extension Clock {
145145
// For compatibility, return `nil` if this is not implemented
146-
public func _convert(from duration: Duration) -> Swift.Duration? {
146+
public func convert(from duration: Duration) -> Swift.Duration? {
147147
return nil
148148
}
149149

150-
public func _convert(from duration: Swift.Duration) -> Duration? {
150+
public func convert(from duration: Swift.Duration) -> Duration? {
151151
return nil
152152
}
153153

154-
public func _convert<OtherClock: Clock>(instant: OtherClock.Instant,
155-
from clock: OtherClock) -> Instant? {
154+
public func convert<OtherClock: Clock>(instant: OtherClock.Instant,
155+
from clock: OtherClock) -> Instant? {
156156
let ourNow = now
157157
let otherNow = clock.now
158158
let otherDuration = otherNow.duration(to: instant)
159159

160160
// Convert to `Swift.Duration`
161-
guard let duration = clock._convert(from: otherDuration) else {
161+
guard let duration = clock.convert(from: otherDuration) else {
162162
return nil
163163
}
164164

165165
// Convert from `Swift.Duration`
166-
guard let ourDuration = _convert(from: duration) else {
166+
guard let ourDuration = convert(from: duration) else {
167167
return nil
168168
}
169169

@@ -173,7 +173,7 @@ extension Clock {
173173

174174
@available(SwiftStdlib 6.2, *)
175175
extension Clock where Duration == Swift.Duration {
176-
public func _convert(from duration: Duration) -> Duration? {
176+
public func convert(from duration: Duration) -> Duration? {
177177
return duration
178178
}
179179
}
@@ -208,28 +208,28 @@ extension Clock {
208208
/// time or delay in. Executors are expected to do this on a best effort
209209
/// basis.
210210
@available(SwiftStdlib 6.2, *)
211-
public struct _ClockTraits: OptionSet {
211+
public struct ClockTraits: OptionSet {
212212
public let rawValue: UInt32
213213

214214
public init(rawValue: UInt32) {
215215
self.rawValue = rawValue
216216
}
217217

218218
/// Clocks with this trait continue running while the machine is asleep.
219-
public static let continuous = _ClockTraits(rawValue: 1 << 0)
219+
public static let continuous = ClockTraits(rawValue: 1 << 0)
220220

221221
/// Indicates that a clock's time will only ever increase.
222-
public static let monotonic = _ClockTraits(rawValue: 1 << 1)
222+
public static let monotonic = ClockTraits(rawValue: 1 << 1)
223223

224224
/// Clocks with this trait are tied to "wall time".
225-
public static let wallTime = _ClockTraits(rawValue: 1 << 2)
225+
public static let wallTime = ClockTraits(rawValue: 1 << 2)
226226
}
227227

228228
@available(SwiftStdlib 6.2, *)
229229
extension Clock {
230230
/// The traits associated with this clock instance.
231231
@available(SwiftStdlib 6.2, *)
232-
public var _traits: _ClockTraits {
232+
public var traits: ClockTraits {
233233
return []
234234
}
235235
}

stdlib/public/Concurrency/ContinuousClock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extension ContinuousClock: Clock {
102102

103103
/// The continuous clock is continuous and monotonic
104104
@available(SwiftStdlib 6.2, *)
105-
public var _traits: _ClockTraits {
105+
public var traits: ClockTraits {
106106
return [.continuous, .monotonic]
107107
}
108108

stdlib/public/Concurrency/CooperativeExecutor.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@ import Swift
2121
extension ExecutorJob {
2222
fileprivate var cooperativeExecutorTimestampIsIndirect: Bool {
2323
return MemoryLayout<(Int, Int)>.size
24-
< MemoryLayout<_CooperativeExecutor.Timestamp>.size
24+
< MemoryLayout<CooperativeExecutor.Timestamp>.size
2525
}
2626

27-
fileprivate var cooperativeExecutorTimestampPointer: UnsafeMutablePointer<_CooperativeExecutor.Timestamp> {
27+
fileprivate var cooperativeExecutorTimestampPointer: UnsafeMutablePointer<CooperativeExecutor.Timestamp> {
2828
get {
2929
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) {
3232
return unsafe $0[0]
3333
}
3434
}
3535
}
3636
set {
3737
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) {
4040
unsafe $0[0] = newValue
4141
}
4242
}
4343
}
4444
}
4545

46-
fileprivate var cooperativeExecutorTimestamp: _CooperativeExecutor.Timestamp {
46+
fileprivate var cooperativeExecutorTimestamp: CooperativeExecutor.Timestamp {
4747
get {
4848
if cooperativeExecutorTimestampIsIndirect {
4949
let ptr = unsafe cooperativeExecutorTimestampPointer
5050
return unsafe ptr.pointee
5151
} else {
52-
return unsafe _withUnsafeExecutorPrivateData {
52+
return unsafe withUnsafeExecutorPrivateData {
5353
return unsafe $0.assumingMemoryBound(
54-
to: _CooperativeExecutor.Timestamp.self
54+
to: CooperativeExecutor.Timestamp.self
5555
)[0]
5656
}
5757
}
@@ -61,8 +61,8 @@ extension ExecutorJob {
6161
let ptr = unsafe cooperativeExecutorTimestampPointer
6262
unsafe ptr.pointee = newValue
6363
} else {
64-
unsafe _withUnsafeExecutorPrivateData {
65-
unsafe $0.withMemoryRebound(to: _CooperativeExecutor.Timestamp.self) {
64+
unsafe withUnsafeExecutorPrivateData {
65+
unsafe $0.withMemoryRebound(to: CooperativeExecutor.Timestamp.self) {
6666
unsafe $0[0] = newValue
6767
}
6868
}
@@ -73,10 +73,10 @@ extension ExecutorJob {
7373
fileprivate mutating func setupCooperativeExecutorTimestamp() {
7474
// If a Timestamp won't fit, allocate
7575
if cooperativeExecutorTimestampIsIndirect {
76-
let ptr: UnsafeMutablePointer<_CooperativeExecutor.Timestamp>
76+
let ptr: UnsafeMutablePointer<CooperativeExecutor.Timestamp>
7777
// Try to use the task allocator if it has one
7878
if let allocator {
79-
unsafe ptr = allocator.allocate(as: _CooperativeExecutor.Timestamp.self)
79+
unsafe ptr = allocator.allocate(as: CooperativeExecutor.Timestamp.self)
8080
} else {
8181
unsafe ptr = .allocate(capacity: 1)
8282
}
@@ -100,7 +100,7 @@ extension ExecutorJob {
100100
/// A co-operative executor that can be used as the main executor or as a
101101
/// task executor.
102102
@available(SwiftStdlib 6.2, *)
103-
class _CooperativeExecutor: Executor, @unchecked Sendable {
103+
class CooperativeExecutor: Executor, @unchecked Sendable {
104104
var runQueue: PriorityQueue<UnownedJob>
105105
var waitQueue: PriorityQueue<UnownedJob>
106106
var shouldStop: Bool = false
@@ -174,13 +174,13 @@ class _CooperativeExecutor: Executor, @unchecked Sendable {
174174
runQueue.push(UnownedJob(job))
175175
}
176176

177-
public var _isMainExecutor: Bool { true }
177+
public var isMainExecutor: Bool { true }
178178

179-
public var _asSchedulable: any _SchedulableExecutor { self }
179+
public var asSchedulable: any SchedulableExecutor { self }
180180
}
181181

182182
@available(SwiftStdlib 6.2, *)
183-
extension _CooperativeExecutor: _SchedulableExecutor {
183+
extension CooperativeExecutor: SchedulableExecutor {
184184
var currentTime: Timestamp {
185185
var now: Timestamp = .zero
186186
unsafe _getTime(seconds: &now.seconds,
@@ -189,11 +189,11 @@ extension _CooperativeExecutor: _SchedulableExecutor {
189189
return now
190190
}
191191

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)!)
197197
let deadline = self.currentTime + duration
198198

199199
job.setupCooperativeExecutorTimestamp()
@@ -203,12 +203,12 @@ extension _CooperativeExecutor: _SchedulableExecutor {
203203
}
204204

205205
@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 }
209209
}
210210

211-
public func _runUntil(_ condition: () -> Bool) throws {
211+
public func runUntil(_ condition: () -> Bool) throws {
212212
shouldStop = false
213213
while !shouldStop && !condition() {
214214
// Process the timer queue
@@ -244,18 +244,18 @@ extension _CooperativeExecutor: _RunLoopExecutor {
244244
}
245245
}
246246

247-
public func _stop() {
247+
public func stop() {
248248
shouldStop = true
249249
}
250250
}
251251

252252
@available(SwiftStdlib 6.2, *)
253-
extension _CooperativeExecutor: SerialExecutor {}
253+
extension CooperativeExecutor: SerialExecutor {}
254254

255255
@available(SwiftStdlib 6.2, *)
256-
extension _CooperativeExecutor: TaskExecutor {}
256+
extension CooperativeExecutor: TaskExecutor {}
257257

258258
@available(SwiftStdlib 6.2, *)
259-
extension _CooperativeExecutor: _MainExecutor {}
259+
extension CooperativeExecutor: MainExecutor {}
260260

261261
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY

0 commit comments

Comments
 (0)