From fd1440de183349c97c38e67a86859871469a5fef Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 23 Jun 2025 16:45:13 +0100 Subject: [PATCH 01/11] [Concurrency] Updates after second SE pitch. We no longer attempt to convert timestamps from the passed-in `Clock` in order to allow any clock to work with any executor. Instead, executors that do not recognise a clock should call the `enqueue` function on that `Clock`, which lets the `Clock` itself decide how to proceed. Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`. --- stdlib/public/Concurrency/Clock.swift | 223 +++++++------- .../public/Concurrency/ContinuousClock.swift | 6 - .../Concurrency/CooperativeExecutor.swift | 55 +++- .../public/Concurrency/DispatchExecutor.swift | 222 +++++++------- stdlib/public/Concurrency/Executor.swift | 55 ++-- stdlib/public/Concurrency/ExecutorImpl.swift | 22 +- .../public/Concurrency/PartialAsyncTask.swift | 42 +++ .../public/Concurrency/SuspendingClock.swift | 6 - stdlib/public/Concurrency/TaskSleep.swift | 8 +- .../Concurrency/TaskSleepDuration.swift | 96 +++--- .../async_task_executor_nsobject.swift | 13 +- test/Concurrency/Runtime/clocks.swift | 276 ------------------ test/Concurrency/Runtime/sleep_executor.swift | 15 +- .../Inputs/macOS/arm64/concurrency/baseline | 99 +++---- .../macOS/arm64/concurrency/baseline-asserts | 99 +++---- .../Inputs/macOS/x86_64/concurrency/baseline | 99 +++---- .../macOS/x86_64/concurrency/baseline-asserts | 99 +++---- 17 files changed, 642 insertions(+), 793 deletions(-) delete mode 100644 test/Concurrency/Runtime/clocks.swift diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index 39e08c9bd9a8b..6bad7350b5f38 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -34,57 +34,154 @@ import Swift public protocol Clock: Sendable { associatedtype Duration associatedtype Instant: InstantProtocol where Instant.Duration == Duration + associatedtype CanonicalClock: Clock = Self var now: Instant { get } var minimumResolution: Instant.Duration { get } #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY func sleep(until deadline: Instant, tolerance: Instant.Duration?) async throws -#endif - /// The traits associated with this clock instance. + /// Run the given job on an unspecified executor at some point + /// after the given instant. + /// + /// Parameters: + /// + /// - job: The job we wish to run + /// - at instant: The time at which we would like it to run. + /// - tolerance: The ideal maximum delay we are willing to tolerate. + /// @available(StdlibDeploymentTarget 6.2, *) - var traits: ClockTraits { get } + func run(_ job: consuming ExecutorJob, + at instant: Instant, tolerance: Duration?) - /// Convert a Clock-specific Duration to a Swift Duration + /// Enqueue the given job on the specified executor at some point after the + /// given instant. /// - /// Some clocks may define `C.Duration` to be something other than a - /// `Swift.Duration`, but that makes it tricky to convert timestamps - /// between clocks, which is something we want to be able to support. - /// This method will convert whatever `C.Duration` is to a `Swift.Duration`. + /// The default implementation uses the `run` method to trigger a job that + /// does `executor.enqueue(job)`. If a particular `Clock` knows that the + /// executor it has been asked to use is the same one that it will run jobs + /// on, it can short-circuit this behaviour and directly use `run` with + /// the original job. /// /// Parameters: /// - /// - from duration: The `Duration` to convert + /// - job: The job we wish to run + /// - on executor: The executor on which we would like it to run. + /// - at instant: The time at which we would like it to run. + /// - tolerance: The ideal maximum delay we are willing to tolerate. /// - /// Returns: A `Swift.Duration` representing the equivalent duration, or - /// `nil` if this function is not supported. @available(StdlibDeploymentTarget 6.2, *) - func convert(from duration: Duration) -> Swift.Duration? + func enqueue(_ job: consuming ExecutorJob, + on executor: some Executor, + at instant: Instant, tolerance: Duration?) +#endif - /// Convert a Swift Duration to a Clock-specific Duration + /// Obtain the equivalent, canonical clock, or `nil` if this clock + /// is already canonical. + /// + /// A non-canonical clock is a clock with some relationship to a base, + /// canonical, clock, to which it can be converted. + @available(StdlibDeploymentTarget 6.2, *) + var canonicalClock: CanonicalClock? { get } + + /// Convert an Instant to the canonical clock's equivalent Instant. /// /// Parameters: /// - /// - from duration: The `Swift.Duration` to convert. + /// - instant: The `Instant` to convert. /// - /// Returns: A `Duration` representing the equivalent duration, or - /// `nil` if this function is not supported. - @available(StdlibDeploymentTarget 6.2, *) - func convert(from duration: Swift.Duration) -> Duration? + /// Returns: + /// + /// The equivalent `CanonicalClock.Instant`. + func convertToCanonical(instant: Instant) -> CanonicalClock.Instant - /// Convert an `Instant` from some other clock's `Instant` + /// Convert a Duration to the canonical clock's equivalent Duration. /// /// Parameters: /// - /// - instant: The instant to convert. - // - from clock: The clock to convert from. + /// - duration: The `Duration` to convert. + /// + /// Returns: + /// + /// The equivalent `CanonicalClock.Duration`. + func convertToCanonical(duration: Duration) -> CanonicalClock.Duration + + /// Convert an Instant to the canonical clock's equivalent Instant. + /// + /// Parameters: + /// + /// - instant: The `Instant` to convert, or `nil`. + /// + /// Returns: + /// + /// The equivalent `CanonicalClock.Instant`, or `nil` if `instant` was `nil`. + func maybeConvertToCanonical(instant: Instant?) -> CanonicalClock.Instant? + + /// Convert a Duration to the canonical clock's equivalent Duration. + /// + /// Parameters: /// - /// Returns: An `Instant` representing the equivalent instant, or - /// `nil` if this function is not supported. + /// - duration: The `Duration` to convert, or `nil`. + /// + /// Returns: + /// + /// The equivalent `CanonicalClock.Duration`, or `nil` if `duration` was `nil`. + func maybeConvertToCanonical(duration: Duration?) -> CanonicalClock.Duration? +} + +extension Clock { + // The default implementation works by creating a trampoline and calling + // the run() method. @available(StdlibDeploymentTarget 6.2, *) - func convert(instant: OtherClock.Instant, - from clock: OtherClock) -> Instant? + public func enqueue(_ job: consuming ExecutorJob, + on executor: some Executor, + at instant: Instant, tolerance: Duration?) { + let trampoline = job.createTrampoline(to: executor) + run(trampoline, at: instant, tolerance: tolerance) + } + + // Clocks that do not implement run will fatalError() if you try to use + // them with an executor that does not understand them. + @available(StdlibDeploymentTarget 6.2, *) + public func run(_ job: consuming ExecutorJob, + at instant: Instant, tolerance: Duration?) { + fatalError("\(Self.self) does not implement run(_:at:tolerance:).") + } +} + +// Default implementations for canonicalization support +extension Clock where CanonicalClock == Self { + public var canonicalClock: CanonicalClock? { return nil } + + public func convertToCanonical(duration: Duration) -> CanonicalClock.Duration { + return duration + } + + public func convertToCanonical(instant: Instant) -> CanonicalClock.Instant { + return instant + } +} + +// nil-propagating versions of convertToCanonical() +extension Clock { + public func maybeConvertToCanonical(duration: Duration?) + -> CanonicalClock.Duration? + { + if let duration { + return convertToCanonical(duration: duration) + } + return nil + } + + public func maybeConvertToCanonical(instant: Instant?) + -> CanonicalClock.Instant? + { + if let instant { + return convertToCanonical(instant: instant) + } + return nil + } } @available(StdlibDeploymentTarget 5.7, *) @@ -140,44 +237,6 @@ extension Clock { } } -@available(StdlibDeploymentTarget 6.2, *) -extension Clock { - // For compatibility, return `nil` if this is not implemented - public func convert(from duration: Duration) -> Swift.Duration? { - return nil - } - - public func convert(from duration: Swift.Duration) -> Duration? { - return nil - } - - public func convert(instant: OtherClock.Instant, - from clock: OtherClock) -> Instant? { - let ourNow = now - let otherNow = clock.now - let otherDuration = otherNow.duration(to: instant) - - // Convert to `Swift.Duration` - guard let duration = clock.convert(from: otherDuration) else { - return nil - } - - // Convert from `Swift.Duration` - guard let ourDuration = convert(from: duration) else { - return nil - } - - return ourNow.advanced(by: ourDuration) - } -} - -@available(StdlibDeploymentTarget 6.2, *) -extension Clock where Duration == Swift.Duration { - public func convert(from duration: Duration) -> Duration? { - return duration - } -} - #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @available(StdlibDeploymentTarget 5.7, *) extension Clock { @@ -196,44 +255,6 @@ extension Clock { } #endif -/// Represents traits of a particular Clock implementation. -/// -/// Clocks may be of a number of different varieties; executors will likely -/// have specific clocks that they can use to schedule jobs, and will -/// therefore need to be able to convert timestamps to an appropriate clock -/// when asked to enqueue a job with a delay or deadline. -/// -/// Choosing a clock in general requires the ability to tell which of their -/// clocks best matches the clock that the user is trying to specify a -/// time or delay in. Executors are expected to do this on a best effort -/// basis. -@available(StdlibDeploymentTarget 6.2, *) -public struct ClockTraits: OptionSet { - public let rawValue: UInt32 - - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - - /// Clocks with this trait continue running while the machine is asleep. - public static let continuous = ClockTraits(rawValue: 1 << 0) - - /// Indicates that a clock's time will only ever increase. - public static let monotonic = ClockTraits(rawValue: 1 << 1) - - /// Clocks with this trait are tied to "wall time". - public static let wallTime = ClockTraits(rawValue: 1 << 2) -} - -@available(StdlibDeploymentTarget 6.2, *) -extension Clock { - /// The traits associated with this clock instance. - @available(StdlibDeploymentTarget 6.2, *) - public var traits: ClockTraits { - return [] - } -} - enum _ClockID: Int32 { case continuous = 1 case suspending = 2 diff --git a/stdlib/public/Concurrency/ContinuousClock.swift b/stdlib/public/Concurrency/ContinuousClock.swift index 87db5d75bd72f..df0d3385a57a9 100644 --- a/stdlib/public/Concurrency/ContinuousClock.swift +++ b/stdlib/public/Concurrency/ContinuousClock.swift @@ -100,12 +100,6 @@ extension ContinuousClock: Clock { ) } - /// The continuous clock is continuous and monotonic - @available(StdlibDeploymentTarget 6.2, *) - public var traits: ClockTraits { - return [.continuous, .monotonic] - } - #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY /// Suspend task execution until a given deadline within a tolerance. /// If no tolerance is specified then the system may adjust the deadline diff --git a/stdlib/public/Concurrency/CooperativeExecutor.swift b/stdlib/public/Concurrency/CooperativeExecutor.swift index 3e92e85dde67f..3a5e774f9da78 100644 --- a/stdlib/public/Concurrency/CooperativeExecutor.swift +++ b/stdlib/public/Concurrency/CooperativeExecutor.swift @@ -102,7 +102,9 @@ extension ExecutorJob { @available(StdlibDeploymentTarget 6.2, *) class CooperativeExecutor: Executor, @unchecked Sendable { var runQueue: PriorityQueue + #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY var waitQueue: PriorityQueue + #endif var shouldStop: Bool = false /// Internal representation of a duration for CooperativeExecutor @@ -163,11 +165,14 @@ class CooperativeExecutor: Executor, @unchecked Sendable { public init() { runQueue = PriorityQueue(compare: { $0.priority > $1.priority }) + + #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY waitQueue = PriorityQueue(compare: { ExecutorJob($0).cooperativeExecutorTimestamp < ExecutorJob($1).cooperativeExecutorTimestamp }) + #endif } public func enqueue(_ job: consuming ExecutorJob) { @@ -175,12 +180,16 @@ class CooperativeExecutor: Executor, @unchecked Sendable { } public var isMainExecutor: Bool { true } - - public var asSchedulable: any SchedulableExecutor { self } } +#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @available(StdlibDeploymentTarget 6.2, *) -extension CooperativeExecutor: SchedulableExecutor { +extension CooperativeExecutor: SchedulingExecutor { + + public var asScheduling: (any SchedulingExecutor)? { + return self + } + var currentTime: Timestamp { var now: Timestamp = .zero unsafe _getTime(seconds: &now.seconds, @@ -193,14 +202,45 @@ extension CooperativeExecutor: SchedulableExecutor { after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { - let duration = Duration(from: clock.convert(from: delay)!) + // Convert the clock to its canonical equivalent, if any + if let canonical = clock.canonicalClock { + enqueueImpl(job, + after: clock.convertToCanonical(duration: delay), + tolerance: clock.maybeConvertToCanonical(duration: tolerance), + clock: canonical) + return + } + + enqueueImpl(job, after: delay, tolerance: tolerance, clock: clock) + } + + private func enqueueImpl(_ job: consuming ExecutorJob, + after delay: C.Duration, + tolerance: C.Duration? = nil, + clock: C) { + // If it's a clock we know, get the duration to wait + let duration: Duration + if let _ = clock as? ContinuousClock { + // We would need to add a second wait queue to support this + fatalError("CooperativeExecutor currently only supports suspending waits") + } else if let _ = clock as? SuspendingClock { + let suspendingDuration = delay as! SuspendingClock.Duration + duration = Duration(from: suspendingDuration) + } else { + clock.enqueue(job, on: self, at: clock.now.advanced(by: delay), + tolerance: tolerance) + return + } + let deadline = self.currentTime + duration job.setupCooperativeExecutorTimestamp() job.cooperativeExecutorTimestamp = deadline waitQueue.push(UnownedJob(job)) } + } +#endif @available(StdlibDeploymentTarget 6.2, *) extension CooperativeExecutor: RunLoopExecutor { @@ -211,6 +251,7 @@ extension CooperativeExecutor: RunLoopExecutor { public func runUntil(_ condition: () -> Bool) throws { shouldStop = false while !shouldStop && !condition() { + #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY // Process the timer queue let now = currentTime while let job = waitQueue.pop(when: { @@ -220,6 +261,7 @@ extension CooperativeExecutor: RunLoopExecutor { theJob.clearCooperativeExecutorTimestamp() runQueue.push(job) } + #endif // Now run any queued jobs while let job = runQueue.pop() { @@ -228,6 +270,7 @@ extension CooperativeExecutor: RunLoopExecutor { ) } + #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY // Finally, wait until the next deadline if let job = waitQueue.top { let deadline = ExecutorJob(job).cooperativeExecutorTimestamp @@ -241,6 +284,10 @@ extension CooperativeExecutor: RunLoopExecutor { // Stop if no more jobs are available break } + #else // $Embedded || SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY + // Stop if no more jobs are available + break + #endif } } diff --git a/stdlib/public/Concurrency/DispatchExecutor.swift b/stdlib/public/Concurrency/DispatchExecutor.swift index 8ba61976f1d4a..29a5a0d9a2dd5 100644 --- a/stdlib/public/Concurrency/DispatchExecutor.swift +++ b/stdlib/public/Concurrency/DispatchExecutor.swift @@ -24,7 +24,8 @@ import Swift // .. Main Executor ............................................................ @available(StdlibDeploymentTarget 6.2, *) -public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable { +public class DispatchMainExecutor: RunLoopExecutor, SchedulingExecutor, + @unchecked Sendable { var threaded = false public init() {} @@ -41,6 +42,18 @@ public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable { public func stop() { fatalError("DispatchMainExecutor cannot be stopped") } + + var asScheduling: (any SchedulingExecutor)? { + return self + } + + public func enqueue(_ job: consuming ExecutorJob, + at instant: C.Instant, + tolerance: C.Duration? = nil, + clock: C) { + _dispatchEnqueue(job, at: instant, tolerance: tolerance, clock: clock, + executor: self, global: false) + } } @available(StdlibDeploymentTarget 6.2, *) @@ -57,41 +70,13 @@ extension DispatchMainExecutor: SerialExecutor { } } -@available(StdlibDeploymentTarget 6.2, *) -extension DispatchMainExecutor: SchedulableExecutor { - public var asSchedulable: SchedulableExecutor? { - return self - } - - public func enqueue(_ job: consuming ExecutorJob, - at instant: C.Instant, - tolerance: C.Duration? = nil, - clock: C) { - let tolSec, tolNanosec: CLongLong - if let tolerance = tolerance { - (tolSec, tolNanosec) = delay(from: tolerance, clock: clock) - } else { - tolSec = 0 - tolNanosec = -1 - } - - let (clockID, seconds, nanoseconds) = timestamp(for: instant, clock: clock) - - _dispatchEnqueueWithDeadline(CBool(false), - CLongLong(seconds), CLongLong(nanoseconds), - CLongLong(tolSec), CLongLong(tolNanosec), - clockID.rawValue, - UnownedJob(job)) - } -} - @available(StdlibDeploymentTarget 6.2, *) extension DispatchMainExecutor: MainExecutor {} // .. Task Executor ............................................................ @available(StdlibDeploymentTarget 6.2, *) -public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor, +public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor, @unchecked Sendable { public init() {} @@ -101,112 +86,129 @@ public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor, public var isMainExecutor: Bool { false } + var asScheduling: (any SchedulingExecutor)? { + return self + } + public func enqueue(_ job: consuming ExecutorJob, at instant: C.Instant, tolerance: C.Duration? = nil, clock: C) { - let tolSec, tolNanosec: CLongLong - if let tolerance = tolerance { - (tolSec, tolNanosec) = delay(from: tolerance, clock: clock) - } else { - tolSec = 0 - tolNanosec = -1 - } - - let (clockID, seconds, nanoseconds) = timestamp(for: instant, clock: clock) - - _dispatchEnqueueWithDeadline(CBool(true), - CLongLong(seconds), CLongLong(nanoseconds), - CLongLong(tolSec), CLongLong(tolNanosec), - clockID.rawValue, - UnownedJob(job)) + _dispatchEnqueue(job, at: instant, tolerance: tolerance, clock: clock, + executor: self, global: true) } } // .. Clock Support ............................................................ -/// DispatchMainExecutor and DispatchTaskExecutor both implement this -/// protocol. -/// -/// It is used to help convert instants and durations from arbitrary `Clock`s -/// to Dispatch's time base. -@available(StdlibDeploymentTarget 6.2, *) -protocol DispatchExecutorProtocol: Executor { - - /// Convert an `Instant` from the specified clock to a tuple identifying - /// the Dispatch clock and the seconds and nanoseconds components. - /// - /// Parameters: - /// - /// - for instant: The `Instant` to convert. - /// - clock: The `Clock` instant that the `Instant` came from. - /// - /// Returns: A tuple of `(clockID, seconds, nanoseconds)`. - func timestamp(for instant: C.Instant, clock: C) - -> (clockID: DispatchClockID, seconds: Int64, nanoseconds: Int64) - - /// Convert a `Duration` from the specified clock to a tuple containing - /// seconds and nanosecond components. - func delay(from duration: C.Duration, clock: C) - -> (seconds: Int64, nanoseconds: Int64) - -} - /// An enumeration identifying one of the Dispatch-supported clocks enum DispatchClockID: CInt { case continuous = 1 case suspending = 2 } -@available(StdlibDeploymentTarget 6.2, *) -extension DispatchExecutorProtocol { - - func clamp(_ components: (seconds: Int64, attoseconds: Int64)) - -> (seconds: Int64, attoseconds: Int64) { - if components.seconds < 0 - || components.seconds == 0 && components.attoseconds < 0 { - return (seconds: 0, attoseconds: 0) - } - return (seconds: components.seconds, attoseconds: components.attoseconds) +fileprivate func clamp(_ components: (seconds: Int64, attoseconds: Int64)) + -> (seconds: Int64, attoseconds: Int64) { + if components.seconds < 0 + || components.seconds == 0 && components.attoseconds < 0 { + return (seconds: 0, attoseconds: 0) } + return (seconds: components.seconds, attoseconds: components.attoseconds) +} - func timestamp(for instant: C.Instant, clock: C) - -> (clockID: DispatchClockID, seconds: Int64, nanoseconds: Int64) { - if clock.traits.contains(.continuous) { - let dispatchClock: ContinuousClock = .continuous - let instant = dispatchClock.convert(instant: instant, from: clock)! - let (seconds, attoseconds) = clamp(instant._value.components) - let nanoseconds = attoseconds / 1_000_000_000 - return (clockID: .continuous, - seconds: Int64(seconds), - nanoseconds: Int64(nanoseconds)) - } else { - let dispatchClock: SuspendingClock = .suspending - let instant = dispatchClock.convert(instant: instant, from: clock)! - let (seconds, attoseconds) = clamp(instant._value.components) - let nanoseconds = attoseconds / 1_000_000_000 - return (clockID: .suspending, - seconds: Int64(seconds), - nanoseconds: Int64(nanoseconds)) - } - } +fileprivate func delay(from duration: Swift.Duration) -> ( + seconds: Int64, nanoseconds: Int64 +) { + let (seconds, attoseconds) = clamp(duration.components) + let nanoseconds = attoseconds / 1_000_000_000 + return (seconds: seconds, nanoseconds: nanoseconds) +} - func delay(from duration: C.Duration, clock: C) - -> (seconds: Int64, nanoseconds: Int64) { - let swiftDuration = clock.convert(from: duration)! - let (seconds, attoseconds) = clamp(swiftDuration.components) - let nanoseconds = attoseconds / 1_000_000_000 - return (seconds: seconds, nanoseconds: nanoseconds) +fileprivate func timestamp(for instant: C.Instant, clock: C) + -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64)? { + if let continuousClock = clock as? ContinuousClock { + return continuousClock.timestamp(for: instant as! ContinuousClock.Instant) + } else if let suspendingClock = clock as? SuspendingClock { + return suspendingClock.timestamp(for: instant as! SuspendingClock.Instant) } + return nil +} +fileprivate func durationComponents(for duration: C.Duration, clock: C) + -> (seconds: Int64, nanoseconds: Int64) { + if let continuousClock = clock as? ContinuousClock { + return continuousClock.durationComponents(for: duration as! ContinuousClock.Duration) + } else if let suspendingClock = clock as? SuspendingClock { + return suspendingClock.durationComponents(for: duration as! SuspendingClock.Duration) + } + // This shouldn't be reachable + fatalError("unknown clock in Dispatch Executor") } @available(StdlibDeploymentTarget 6.2, *) -extension DispatchGlobalTaskExecutor: DispatchExecutorProtocol { +fileprivate func _dispatchEnqueue( + _ job: consuming ExecutorJob, + at instant: C.Instant, + tolerance: C.Duration?, + clock: C, + executor: E, + global: Bool +) { + // Convert the clock to its canonical equivalent, if any + if let canonical = clock.canonicalClock { + _dispatchEnqueueImpl( + job, + at: clock.convertToCanonical(instant: instant), + tolerance: clock.maybeConvertToCanonical(duration: tolerance), + clock: canonical, + executor: executor, + global: global + ) + return + } + + _dispatchEnqueueImpl( + job, + at: instant, + tolerance: tolerance, + clock: clock, + executor: executor, + global: global + ) } @available(StdlibDeploymentTarget 6.2, *) -extension DispatchMainExecutor: DispatchExecutorProtocol { +fileprivate func _dispatchEnqueueImpl( + _ job: consuming ExecutorJob, + at instant: C.Instant, + tolerance: C.Duration?, + clock: C, + executor: E, + global: Bool +) { + // If it's a clock we know, convert it to something we can use; otherwise, + // call the clock's `enqueue` function to schedule the enqueue of the job. + + guard let (clockID, seconds, nanoseconds) = timestamp(for: instant, + clock: clock) else { + clock.enqueue(job, on: executor, at: instant, tolerance: tolerance) + return + } + + let tolSec: Int64, tolNanosec: Int64 + if let tolerance = tolerance { + (tolSec, tolNanosec) = durationComponents(for: tolerance, + clock: clock) + } else { + tolSec = 0 + tolNanosec = -1 + } + + _dispatchEnqueueWithDeadline(CBool(global), + CLongLong(seconds), CLongLong(nanoseconds), + CLongLong(tolSec), CLongLong(tolNanosec), + clockID.rawValue, + UnownedJob(job)) } #endif // !$Embedded && !os(WASI) diff --git a/stdlib/public/Concurrency/Executor.swift b/stdlib/public/Concurrency/Executor.swift index 6b380f7f6dd3c..ecda65b88db18 100644 --- a/stdlib/public/Concurrency/Executor.swift +++ b/stdlib/public/Concurrency/Executor.swift @@ -41,10 +41,21 @@ public protocol Executor: AnyObject, Sendable { @available(StdlibDeploymentTarget 6.2, *) var isMainExecutor: Bool { get } #endif + + #if !$Embedded + /// Return this executable as a SchedulingExecutor, or nil if that is + /// unsupported. + /// + /// Executors that implement SchedulingExecutor should provide their + /// own copy of this method, which will allow the compiler to avoid a + /// potentially expensive runtime cast. + @available(StdlibDeploymentTarget 6.2, *) + var asSchedulingExecutor: (any SchedulingExecutor)? { get } + #endif } @available(StdlibDeploymentTarget 6.2, *) -public protocol SchedulableExecutor: Executor { +public protocol SchedulingExecutor: Executor { #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @@ -119,16 +130,20 @@ extension Actor { } extension Executor { - /// Return this executable as a SchedulableExecutor, or nil if that is + + #if !$Embedded + /// Return this executor as a SchedulingExecutor, or nil if that is /// unsupported. /// - /// Executors that implement SchedulableExecutor should provide their + /// Executors that implement SchedulingExecutor should provide their /// own copy of this method, which will allow the compiler to avoid a /// potentially expensive runtime cast. @available(StdlibDeploymentTarget 6.2, *) - var asSchedulable: SchedulableExecutor? { - return self as? SchedulableExecutor + public var asSchedulingExecutor: (any SchedulingExecutor)? { + return self as? SchedulingExecutor } + #endif + } extension Executor { @@ -156,7 +171,7 @@ extension Executor { // Delay support @available(StdlibDeploymentTarget 6.2, *) -extension SchedulableExecutor { +extension SchedulingExecutor { #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @@ -568,7 +583,7 @@ extension RunLoopExecutor { } -/// The main executor must conform to these three protocols; we have to +/// The main executor must conform to these two protocols; we have to /// make this a protocol for compatibility with Embedded Swift. @available(StdlibDeploymentTarget 6.2, *) public protocol MainExecutor: RunLoopExecutor, SerialExecutor { @@ -680,30 +695,32 @@ extension Task where Success == Never, Failure == Never { return nil } - /// Get the current *schedulable* executor, if any. + #if !$Embedded + /// Get the current *scheduling* executor, if any. /// /// This follows the same logic as `currentExecutor`, except that it ignores - /// any executor that isn't a `SchedulableExecutor`. + /// any executor that isn't a `SchedulingExecutor`. @available(StdlibDeploymentTarget 6.2, *) - @_unavailableInEmbedded - public static var currentSchedulableExecutor: (any SchedulableExecutor)? { + public static var currentSchedulingExecutor: (any SchedulingExecutor)? { if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor(), - let schedulable = activeExecutor.asSchedulable { - return schedulable + let scheduling = activeExecutor.asSchedulingExecutor { + return scheduling } if let taskExecutor = unsafe _getPreferredTaskExecutor().asTaskExecutor(), - let schedulable = taskExecutor.asSchedulable { - return schedulable + let scheduling = taskExecutor.asSchedulingExecutor { + return scheduling } if let taskExecutor = unsafe _getCurrentTaskExecutor().asTaskExecutor(), - let schedulable = taskExecutor.asSchedulable { - return schedulable + let scheduling = taskExecutor.asSchedulingExecutor { + return scheduling } - if let schedulable = defaultExecutor.asSchedulable { - return schedulable + if let scheduling = defaultExecutor.asSchedulingExecutor { + return scheduling } return nil } + #endif + } diff --git a/stdlib/public/Concurrency/ExecutorImpl.swift b/stdlib/public/Concurrency/ExecutorImpl.swift index 7ac153d2a3704..2f6ef7f778751 100644 --- a/stdlib/public/Concurrency/ExecutorImpl.swift +++ b/stdlib/public/Concurrency/ExecutorImpl.swift @@ -76,9 +76,9 @@ internal func enqueueOnGlobalExecutor(job unownedJob: UnownedJob) { internal func enqueueOnGlobalExecutor(delay: CUnsignedLongLong, job unownedJob: UnownedJob) { #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY - Task.defaultExecutor.asSchedulable!.enqueue(ExecutorJob(unownedJob), - after: .nanoseconds(delay), - clock: .continuous) + Task.defaultExecutor.asSchedulingExecutor!.enqueue(ExecutorJob(unownedJob), + after: .nanoseconds(delay), + clock: .continuous) #else fatalError("swift_task_enqueueGlobalWithDelay() not supported for task-to-thread") #endif @@ -97,15 +97,15 @@ internal func enqueueOnGlobalExecutor(seconds: CLongLong, let leeway = Duration.seconds(leewaySeconds) + Duration.nanoseconds(leewayNanoseconds) switch clock { case _ClockID.suspending.rawValue: - Task.defaultExecutor.asSchedulable!.enqueue(ExecutorJob(unownedJob), - after: delay, - tolerance: leeway, - clock: .suspending) + Task.defaultExecutor.asSchedulingExecutor!.enqueue(ExecutorJob(unownedJob), + after: delay, + tolerance: leeway, + clock: .suspending) case _ClockID.continuous.rawValue: - Task.defaultExecutor.asSchedulable!.enqueue(ExecutorJob(unownedJob), - after: delay, - tolerance: leeway, - clock: .continuous) + Task.defaultExecutor.asSchedulingExecutor!.enqueue(ExecutorJob(unownedJob), + after: delay, + tolerance: leeway, + clock: .continuous) default: fatalError("Unknown clock ID \(clock)") } diff --git a/stdlib/public/Concurrency/PartialAsyncTask.swift b/stdlib/public/Concurrency/PartialAsyncTask.swift index 03edb99401dfb..37992ee332793 100644 --- a/stdlib/public/Concurrency/PartialAsyncTask.swift +++ b/stdlib/public/Concurrency/PartialAsyncTask.swift @@ -450,6 +450,48 @@ extension ExecutorJob { } } +// Helper to create a trampoline job to execute a job on a specified +// executor. +extension ExecutorJob { + + /// Create a trampoline to enqueue the specified job on the specified + /// executor. + /// + /// This is useful in conjunction with the `Clock.run()` API, which + /// runs a job on an unspecified executor. + /// + /// Parameters: + /// + /// - to executor: The `Executor` on which it should be enqueued. + /// + /// Returns: + /// + /// A new ExecutorJob that will enqueue the specified job on the specified + /// executor. + @available(StdlibDeploymentTarget 6.2, *) + public func createTrampoline(to executor: some Executor) -> ExecutorJob { + let flags = taskCreateFlags( + priority: TaskPriority(priority), + isChildTask: false, + copyTaskLocals: false, + inheritContext: false, + enqueueJob: false, + addPendingGroupTaskUnconditionally: false, + isDiscardingTask: false, + isSynchronousStart: false + ) + + let unownedJob = UnownedJob(context: self.context) + let (trampolineTask, _) = Builtin.createAsyncTask(flags) { + executor.enqueue(unownedJob) + } + let trampoline = Builtin.convertTaskToJob(trampolineTask) + + return ExecutorJob(context: trampoline) + } + +} + // Stack-disciplined job-local allocator support @available(StdlibDeploymentTarget 6.2, *) extension ExecutorJob { diff --git a/stdlib/public/Concurrency/SuspendingClock.swift b/stdlib/public/Concurrency/SuspendingClock.swift index 0f63aa0fa697f..b8ff0481f8406 100644 --- a/stdlib/public/Concurrency/SuspendingClock.swift +++ b/stdlib/public/Concurrency/SuspendingClock.swift @@ -87,12 +87,6 @@ extension SuspendingClock: Clock { return Duration(_seconds: seconds, nanoseconds: nanoseconds) } - /// The suspending clock is monotonic - @available(StdlibDeploymentTarget 6.2, *) - public var traits: ClockTraits { - return [.monotonic] - } - #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY /// Suspend task execution until a given deadline within a tolerance. /// If no tolerance is specified then the system may adjust the deadline diff --git a/stdlib/public/Concurrency/TaskSleep.swift b/stdlib/public/Concurrency/TaskSleep.swift index c40483bfb4a70..b9994e01698eb 100644 --- a/stdlib/public/Concurrency/TaskSleep.swift +++ b/stdlib/public/Concurrency/TaskSleep.swift @@ -30,7 +30,7 @@ extension Task where Success == Never, Failure == Never { if #available(StdlibDeploymentTarget 6.2, *) { #if !$Embedded - if let executor = Task.currentSchedulableExecutor { + if let executor = Task.currentSchedulingExecutor { executor.enqueue(ExecutorJob(context: job), after: .nanoseconds(duration), clock: .continuous) @@ -39,7 +39,7 @@ extension Task where Success == Never, Failure == Never { #endif } - // If there is no current schedulable executor, fall back to + // If there is no current scheduling executor, fall back to // _enqueueJobGlobalWithDelay() _enqueueJobGlobalWithDelay(duration, job) } @@ -274,7 +274,7 @@ extension Task where Success == Never, Failure == Never { if #available(StdlibDeploymentTarget 6.2, *) { #if !$Embedded - if let executor = Task.currentSchedulableExecutor { + if let executor = Task.currentSchedulingExecutor { executor.enqueue(ExecutorJob(context: job), after: .nanoseconds(duration), clock: .continuous) @@ -283,7 +283,7 @@ extension Task where Success == Never, Failure == Never { #endif } - // If there is no current schedulable executor, fall back to + // If there is no current scheduling executor, fall back to // _enqueueJobGlobalWithDelay() _enqueueJobGlobalWithDelay(duration, job) return diff --git a/stdlib/public/Concurrency/TaskSleepDuration.swift b/stdlib/public/Concurrency/TaskSleepDuration.swift index 7508103149d2d..27f35eb321b7c 100644 --- a/stdlib/public/Concurrency/TaskSleepDuration.swift +++ b/stdlib/public/Concurrency/TaskSleepDuration.swift @@ -13,45 +13,64 @@ import Swift #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY -@available(StdlibDeploymentTarget 5.7, *) -fileprivate func timestamp(for instant: C.Instant, clock: C) - -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) { - var clockID: _ClockID - if #available(StdlibDeploymentTarget 6.2, *) { - if clock.traits.contains(.continuous) { - clockID = .continuous - } else { - clockID = .suspending - } - } else { - fatalError("we shouldn't get here; if we have, availability is broken") +@_unavailableInEmbedded +extension ContinuousClock { + func timestamp(for instant: Instant) + -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) + { + let (seconds, nanoseconds) = durationComponents(for: instant._value) + return (clockID: .continuous, seconds: seconds, nanoseconds: nanoseconds) + } + + func durationComponents(for duration: Duration) + -> (seconds: Int64, nanoseconds: Int64) + { + let (seconds, attoseconds) = duration.components + let nanoseconds = attoseconds / 1_000_000_000 + return (seconds: seconds, nanoseconds: nanoseconds) + } +} + +@_unavailableInEmbedded +extension SuspendingClock { + func timestamp(for instant: Instant) + -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) + { + let (seconds, nanoseconds) = durationComponents(for: instant._value) + return (clockID: .suspending, seconds: seconds, nanoseconds: nanoseconds) } - var seconds: Int64 = 0 - var nanoseconds: Int64 = 0 - unsafe _getTime(seconds: &seconds, - nanoseconds: &nanoseconds, - clock: clockID.rawValue) - - let delta: Swift.Duration - if #available(StdlibDeploymentTarget 6.2, *) { - delta = clock.convert(from: clock.now.duration(to: instant))! - } else { - fatalError("we shouldn't get here; if we have, availability is broken") + func durationComponents(for duration: Duration) + -> (seconds: Int64, nanoseconds: Int64) + { + let (seconds, attoseconds) = duration.components + let nanoseconds = attoseconds / 1_000_000_000 + return (seconds: seconds, nanoseconds: nanoseconds) } +} - let (deltaSeconds, deltaAttoseconds) = delta.components - let deltaNanoseconds = deltaAttoseconds / 1_000_000_000 - seconds += deltaSeconds - nanoseconds += deltaNanoseconds - if nanoseconds > 1_000_000_000 { - seconds += 1 - nanoseconds -= 1_000_000_000 +fileprivate func timestamp(for instant: C.Instant, clock: C) + -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) { + #if !$Embedded + if let continuousClock = clock as? ContinuousClock { + return continuousClock.timestamp(for: instant as! ContinuousClock.Instant) + } else if let suspendingClock = clock as? SuspendingClock { + return suspendingClock.timestamp(for: instant as! SuspendingClock.Instant) } + #endif + fatalError("unknown clock in fallback path") +} - return (clockID: clockID, - seconds: Int64(seconds), - nanoseconds: Int64(nanoseconds)) +fileprivate func durationComponents(for duration: C.Duration, clock: C) + -> (seconds: Int64, nanoseconds: Int64) { + #if !$Embedded + if let continuousClock = clock as? ContinuousClock { + return continuousClock.durationComponents(for: duration as! ContinuousClock.Duration) + } else if let suspendingClock = clock as? SuspendingClock { + return suspendingClock.durationComponents(for: duration as! SuspendingClock.Duration) + } + #endif + fatalError("unknown clock in fallback path") } @available(StdlibDeploymentTarget 5.7, *) @@ -99,7 +118,7 @@ extension Task where Success == Never, Failure == Never { if #available(StdlibDeploymentTarget 6.2, *) { #if !$Embedded - if let executor = Task.currentSchedulableExecutor { + if let executor = Task.currentSchedulingExecutor { executor.enqueue(ExecutorJob(context: job), at: instant, tolerance: tolerance, @@ -111,17 +130,16 @@ extension Task where Success == Never, Failure == Never { fatalError("we shouldn't get here; if we have, availability is broken") } - // If there is no current schedulable executor, fall back to + // If there is no current scheduling executor, fall back to // calling _enqueueJobGlobalWithDeadline(). let (clockID, seconds, nanoseconds) = timestamp(for: instant, clock: clock) let toleranceSeconds: Int64 let toleranceNanoseconds: Int64 if #available(StdlibDeploymentTarget 6.2, *) { - if let tolerance = tolerance, - let components = clock.convert(from: tolerance)?.components { - toleranceSeconds = components.seconds - toleranceNanoseconds = components.attoseconds / 1_000_000_000 + if let tolerance = tolerance { + (toleranceSeconds, toleranceNanoseconds) + = durationComponents(for: tolerance, clock: clock) } else { toleranceSeconds = 0 toleranceNanoseconds = -1 diff --git a/test/Concurrency/Runtime/async_task_executor_nsobject.swift b/test/Concurrency/Runtime/async_task_executor_nsobject.swift index d652f7d246f01..827b76a047bfe 100644 --- a/test/Concurrency/Runtime/async_task_executor_nsobject.swift +++ b/test/Concurrency/Runtime/async_task_executor_nsobject.swift @@ -22,7 +22,7 @@ import Darwin // This test specifically checks that our reference counting accounts for existence of // objective-c types as TaskExecutors -- which was a bug where we'd swift_release // obj-c excecutors by accident (rdar://131151645). -final class NSQueueTaskExecutor: NSData, TaskExecutor, SchedulableExecutor, @unchecked Sendable { +final class NSQueueTaskExecutor: NSData, TaskExecutor, SchedulingExecutor, @unchecked Sendable { public func enqueue(_ _job: consuming ExecutorJob) { let job = UnownedJob(_job) DispatchQueue.main.async { @@ -34,8 +34,17 @@ final class NSQueueTaskExecutor: NSData, TaskExecutor, SchedulableExecutor, @unc after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { + // Convert the clock to its canonical equivalent, if any + if let canonical = clock.canonicalClock { + enqueue(_job, + after: clock.convertToCanonical(duration: delay), + tolerance: clock.maybeConvertToCanonical(duration: tolerance), + clock: canonical) + return + } + // Convert to `Swift.Duration` - let duration = clock.convert(from: delay)! + let duration = delay as! Swift.Duration // Now turn that into nanoseconds let (seconds, attoseconds) = duration.components diff --git a/test/Concurrency/Runtime/clocks.swift b/test/Concurrency/Runtime/clocks.swift deleted file mode 100644 index 731cda3503d42..0000000000000 --- a/test/Concurrency/Runtime/clocks.swift +++ /dev/null @@ -1,276 +0,0 @@ -// RUN: %target-run-simple-swift(%import-libdispatch -parse-as-library) - -// REQUIRES: concurrency -// REQUIRES: executable_test - -// rdar://106849189 move-only types should be supported in freestanding mode -// UNSUPPORTED: freestanding - -// UNSUPPORTED: back_deployment_runtime -// REQUIRES: concurrency_runtime - -import StdlibUnittest - -@available(SwiftStdlib 6.2, *) -struct TickingClock: Clock { - struct Duration: DurationProtocol { - var ticks: Int - - static func / (_ lhs: Self, _ rhs: Int) -> Self { - return Duration(ticks: lhs.ticks / rhs) - } - static func * (_ lhs: Self, rhs: Int) -> Self { - return Duration(ticks: lhs.ticks * rhs) - } - static func / (_ lhs: Self, _ rhs: Self) -> Double { - return Double(lhs.ticks) / Double(rhs.ticks) - } - static func < (_ lhs: Self, _ rhs: Self) -> Bool { - return lhs.ticks < rhs.ticks - } - static func + (_ lhs: Self, _ rhs: Self) -> Self { - return Duration(ticks: lhs.ticks + rhs.ticks) - } - static func - (_ lhs: Self, _ rhs: Self) -> Self { - return Duration(ticks: lhs.ticks - rhs.ticks) - } - - static var zero: Self { - return Duration(ticks: 0) - } - } - struct Instant: InstantProtocol { - typealias Duration = TickingClock.Duration - var ticksFromStart: Int - - func advanced(by duration: Duration) -> Self { - return Instant(ticksFromStart: self.ticksFromStart + duration.ticks) - } - func duration(to other: Self) -> Duration { - return Duration(ticks: other.ticksFromStart - self.ticksFromStart) - } - - static func < (_ lhs: Self, _ rhs: Self) -> Bool { - return lhs.ticksFromStart < rhs.ticksFromStart - } - } - - private var _now: Instant - var now: Instant { return _now } - var minimumResolution: Duration { return Duration(ticks: 1) } - var traits: ClockTraits { [.monotonic] } - - init() { - _now = Instant(ticksFromStart: 0) - } - - // These are a bit of a lie, since this clock is weird and doesn't - // actually tell the time; for the purposes of this test, we pretend - // that the ticks are 20ms. - func convert(from duration: Duration) -> Swift.Duration? { - return .seconds(Double(duration.ticks) / 50) - } - - func convert(from duration: Swift.Duration) -> Duration? { - let (seconds, attoseconds) = duration.components - let extraTicks = attoseconds / 20_000_000_000_000_000 - return Duration(ticks: Int(seconds * 50) + Int(extraTicks)) - } - - mutating func tick() { - _now.ticksFromStart += 1 - } - - func sleep( - until instant: Instant, - tolerance: Duration? = nil - ) async throws { - // Do nothing - } -} - -@available(SwiftStdlib 6.2, *) -struct TockingClock: Clock { - struct Duration: DurationProtocol { - var tocks: Int - - static func / (_ lhs: Self, _ rhs: Int) -> Self { - return Duration(tocks: lhs.tocks / rhs) - } - static func * (_ lhs: Self, rhs: Int) -> Self { - return Duration(tocks: lhs.tocks * rhs) - } - static func / (_ lhs: Self, _ rhs: Self) -> Double { - return Double(lhs.tocks) / Double(rhs.tocks) - } - static func < (_ lhs: Self, _ rhs: Self) -> Bool { - return lhs.tocks < rhs.tocks - } - static func + (_ lhs: Self, _ rhs: Self) -> Self { - return Duration(tocks: lhs.tocks + rhs.tocks) - } - static func - (_ lhs: Self, _ rhs: Self) -> Self { - return Duration(tocks: lhs.tocks - rhs.tocks) - } - - static var zero: Self { - return Duration(tocks: 0) - } - } - struct Instant: InstantProtocol { - typealias Duration = TockingClock.Duration - var tocksFromStart: Int - - func advanced(by duration: Duration) -> Self { - return Instant(tocksFromStart: self.tocksFromStart + duration.tocks) - } - func duration(to other: Self) -> Duration { - return Duration(tocks: other.tocksFromStart - self.tocksFromStart) - } - - static func < (_ lhs: Self, _ rhs: Self) -> Bool { - return lhs.tocksFromStart < rhs.tocksFromStart - } - } - - private var _now: Instant - var now: Instant { return _now } - var minimumResolution: Duration { return Duration(tocks: 1) } - var traits: ClockTraits { [.monotonic] } - - init() { - _now = Instant(tocksFromStart: 1000) - } - - // These are a bit of a lie, since this clock is weird and doesn't - // actually tell the time; for the purposes of this test, we pretend - // that the tocks are 10ms. - func convert(from duration: Duration) -> Swift.Duration? { - return .seconds(Double(duration.tocks) / 100) - } - - func convert(from duration: Swift.Duration) -> Duration? { - let (seconds, attoseconds) = duration.components - let extraTocks = attoseconds / 10_000_000_000_000_000 - return Duration(tocks: Int(seconds * 100) + Int(extraTocks)) - } - - mutating func tock() { - _now.tocksFromStart += 1 - } - - func sleep( - until instant: Instant, - tolerance: Duration? = nil - ) async throws { - // Do nothing - } -} - -@available(SwiftStdlib 6.2, *) -@main struct Main { - static func main() { - let tests = TestSuite("clocks") - - var clockA = TickingClock() - let clockB = TickingClock() - - clockA.tick() - clockA.tick() - clockA.tick() - - var clockC = TockingClock() - - clockC.tock() - - tests.test("Convert instants from one clock to another") { - let nowA = clockA.now - let nowB = clockB.now - - expectEqual(nowA.ticksFromStart, 3) - expectEqual(nowB.ticksFromStart, 0) - - let futureA = nowA.advanced(by: TickingClock.Duration(ticks: 23)) - let futureB = nowB.advanced(by: TickingClock.Duration(ticks: 42)) - - expectEqual(futureA.ticksFromStart, 26) - expectEqual(futureB.ticksFromStart, 42) - - let futureAinB = clockB.convert(instant: futureA, from: clockA)! - let futureBinA = clockA.convert(instant: futureB, from: clockB)! - - expectEqual(futureAinB.ticksFromStart, 23) - expectEqual(futureBinA.ticksFromStart, 45) - - let futureAinBinA = clockA.convert(instant: futureAinB, from: clockB)! - let futureBinAinB = clockB.convert(instant: futureBinA, from: clockA)! - - expectEqual(futureAinBinA.ticksFromStart, futureA.ticksFromStart) - expectEqual(futureBinAinB.ticksFromStart, futureB.ticksFromStart) - } - - tests.test("Convert instants between clocks with different representations") { - let nowA = clockA.now - let nowC = clockC.now - - expectEqual(nowA.ticksFromStart, 3) - expectEqual(nowC.tocksFromStart, 1001) - - let futureA = nowA.advanced(by: TickingClock.Duration(ticks: 23)) - let futureC = nowC.advanced(by: TockingClock.Duration(tocks: 42)) - - expectEqual(futureA.ticksFromStart, 26) - expectEqual(futureC.tocksFromStart, 1043) - - let futureAinC = clockC.convert(instant: futureA, from: clockA)! - let futureCinA = clockA.convert(instant: futureC, from: clockC)! - - expectEqual(futureAinC.tocksFromStart, 1047) - expectEqual(futureCinA.ticksFromStart, 24) - - let futureAinCinA = clockA.convert(instant: futureAinC, from: clockC)! - let futureCinAinC = clockC.convert(instant: futureCinA, from: clockA)! - - expectEqual(futureAinCinA.ticksFromStart, futureA.ticksFromStart) - expectEqual(futureCinAinC.tocksFromStart, futureC.tocksFromStart) - } - - tests.test("Convert instants between continuous and suspending clocks") { - let continuous = ContinuousClock() - let suspending = SuspendingClock() - - let nowC = continuous.now - let nowS = suspending.now - - let futureC = nowC.advanced(by: .seconds(5.3)) - let futureS = nowS.advanced(by: .seconds(4.2)) - - let futureCinS = suspending.convert(instant: futureC, - from: .continuous)! - let futureSinC = continuous.convert(instant: futureS, - from: .suspending)! - - let futureCinSinC = continuous.convert(instant: futureCinS, - from: .suspending)! - let futureSinCinS = suspending.convert(instant: futureSinC, - from: .continuous)! - - // These clocks may not be exact, so allow differences of up to 50ms - var delta1 = futureCinSinC - futureC - var delta2 = futureSinCinS - futureS - - // Duration is not SignedNumeric, so we have to do things this way - if delta1 < .zero { - delta1 = .zero - delta1 - } - if delta2 < .zero { - delta2 = .zero - delta2 - } - - expectLT(delta1, .milliseconds(50)) - expectLT(delta2, .milliseconds(50)) - } - - runAllTests() - } -} diff --git a/test/Concurrency/Runtime/sleep_executor.swift b/test/Concurrency/Runtime/sleep_executor.swift index f4767e5a068b3..d3abe6cb8b9db 100644 --- a/test/Concurrency/Runtime/sleep_executor.swift +++ b/test/Concurrency/Runtime/sleep_executor.swift @@ -21,8 +21,8 @@ actor MyActor { } @available(SwiftStdlib 6.2, *) -final class TestExecutor: TaskExecutor, SchedulableExecutor, @unchecked Sendable { - var asSchedulable: SchedulableExecutor? { +final class TestExecutor: TaskExecutor, SchedulingExecutor, @unchecked Sendable { + var asScheduling: SchedulingExecutor? { return self } @@ -37,8 +37,17 @@ final class TestExecutor: TaskExecutor, SchedulableExecutor, @unchecked Sendable after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { + // Convert the clock to its canonical equivalent, if any + if let canonical = clock.canonicalClock { + enqueue(_job, + after: clock.convertToCanonical(duration: delay), + tolerance: clock.maybeConvertToCanonical(duration: tolerance), + clock: canonical) + return + } + // Convert to `Swift.Duration` - let duration = clock.convert(from: delay)! + let duration = delay as! Swift.Duration // Now turn that into nanoseconds let (seconds, attoseconds) = duration.components diff --git a/test/abi/Inputs/macOS/arm64/concurrency/baseline b/test/abi/Inputs/macOS/arm64/concurrency/baseline index 62c6c49652893..faf82a577e56d 100644 --- a/test/abi/Inputs/macOS/arm64/concurrency/baseline +++ b/test/abi/Inputs/macOS/arm64/concurrency/baseline @@ -1,6 +1,7 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl +_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -25,6 +26,8 @@ _$sScEN _$sScEs5ErrorsMc _$sScF14isMainExecutorSbvgTj _$sScF14isMainExecutorSbvgTq +_$sScF20asSchedulingExecutors0bC0_pSgvgTj +_$sScF20asSchedulingExecutors0bC0_pSgvgTq _$sScF7enqueueyyScJFTj _$sScF7enqueueyyScJFTq _$sScF7enqueueyys11ExecutorJobVnFTj @@ -37,6 +40,8 @@ _$sScFsE14isMainExecutorSbvg _$sScFsE14isMainExecutorSbvpMV _$sScFsE18_isComplexEqualitySbvg _$sScFsE18_isComplexEqualitySbvpMV +_$sScFsE20asSchedulingExecutors0bC0_pSgvg +_$sScFsE20asSchedulingExecutors0bC0_pSgvpMV _$sScFsE7enqueueyyScJF _$sScFsE7enqueueyys11ExecutorJobVnF _$sScFsE7enqueueyys3JobVnF @@ -219,8 +224,8 @@ _$sScTss5NeverORszABRs_rlE15defaultExecutorSch_pvpZMV _$sScTss5NeverORszABRs_rlE17checkCancellationyyKFZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvgZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvpZMV -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvgZ -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvpZMV +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvgZ +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvpZMV _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZTu _$sScTss5NeverORszABRs_rlE5sleep5until9tolerance5clocky7InstantQyd___8DurationQyd__Sgqd__tYaKs5ClockRd__lFZ @@ -405,23 +410,6 @@ _$sSctN _$sSctSHsMc _$sSctSQsMc _$ss039_checkIllegalTaskLocalBindingWithinWithC5Group4file4lineySS_SutF -_$ss11ClockTraitsV10continuousABvgZ -_$ss11ClockTraitsV10continuousABvpZMV -_$ss11ClockTraitsV8rawValueABs6UInt32V_tcfC -_$ss11ClockTraitsV8rawValues6UInt32Vvg -_$ss11ClockTraitsV8rawValues6UInt32VvpMV -_$ss11ClockTraitsV8wallTimeABvgZ -_$ss11ClockTraitsV8wallTimeABvpZMV -_$ss11ClockTraitsV9monotonicABvgZ -_$ss11ClockTraitsV9monotonicABvpZMV -_$ss11ClockTraitsVMa -_$ss11ClockTraitsVMn -_$ss11ClockTraitsVN -_$ss11ClockTraitsVSQsMc -_$ss11ClockTraitsVSYsMc -_$ss11ClockTraitsVs10SetAlgebrasMc -_$ss11ClockTraitsVs25ExpressibleByArrayLiteralsMc -_$ss11ClockTraitsVs9OptionSetsMc _$ss11ExecutorJobV010withUnsafeA11PrivateData4bodyxxSwq_YKXE_tq_YKs5ErrorR_r0_lF _$ss11ExecutorJobV11descriptionSSvg _$ss11ExecutorJobV14LocalAllocatorV10deallocateyySpyxGlF @@ -433,6 +421,7 @@ _$ss11ExecutorJobV14LocalAllocatorV8allocate8capacitySwSi_tF _$ss11ExecutorJobV14LocalAllocatorVMa _$ss11ExecutorJobV14LocalAllocatorVMn _$ss11ExecutorJobV14LocalAllocatorVN +_$ss11ExecutorJobV16createTrampoline2toABx_tScFRzlF _$ss11ExecutorJobV4KindV13firstReservedADvgZ _$ss11ExecutorJobV4KindV13firstReservedADvpZMV _$ss11ExecutorJobV4KindV4taskADvgZ @@ -516,8 +505,6 @@ _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15ContinuousClockV6traitss0B6TraitsVvg -_$ss15ContinuousClockV6traitss0B6TraitsVvpMV _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV2eeoiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV3nowADvgZ @@ -566,8 +553,6 @@ _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15SuspendingClockV6traitss0B6TraitsVvg -_$ss15SuspendingClockV6traitss0B6TraitsVvpMV _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ _$ss15SuspendingClockV7InstantV1poiyA2D_s8DurationVtFZ _$ss15SuspendingClockV7InstantV1soiyA2D_s8DurationVtFZ @@ -619,6 +604,15 @@ _$ss16AsyncMapSequenceVMa _$ss16AsyncMapSequenceVMn _$ss16AsyncMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss16AsyncMapSequenceVyxq_GScisMc +_$ss18SchedulingExecutorMp +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorPScFTb +_$ss18SchedulingExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorTL _$ss19AsyncFilterSequenceV04makeA8IteratorAB0E0Vyx_GyF _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvg _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvpMV @@ -676,15 +670,6 @@ _$ss19DiscardingTaskGroupV9cancelAllyyF _$ss19DiscardingTaskGroupVMa _$ss19DiscardingTaskGroupVMn _$ss19DiscardingTaskGroupVN -_$ss19SchedulableExecutorMp -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorPScFTb -_$ss19SchedulableExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorTL _$ss19UnownedTaskExecutorV02asbC0Sch_pSgyF _$ss19UnownedTaskExecutorVyABxhcSchRzlufC _$ss20AsyncFlatMapSequenceV04makeA8IteratorAB0F0Vyxq__GyF @@ -718,14 +703,13 @@ _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc _$ss20DispatchMainExecutorC02isbC0Sbvg _$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvg -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvpMV _$ss20DispatchMainExecutorC13checkIsolatedyyF _$ss20DispatchMainExecutorC3runyyKFTj _$ss20DispatchMainExecutorC3runyyKFTq _$ss20DispatchMainExecutorC4stopyyFTj _$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlF +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq _$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF _$ss20DispatchMainExecutorCABycfC _$ss20DispatchMainExecutorCABycfCTj @@ -743,8 +727,8 @@ _$ss20DispatchMainExecutorCScfsMc _$ss20DispatchMainExecutorCScfsWP _$ss20DispatchMainExecutorCfD _$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs011SchedulableC0sMc -_$ss20DispatchMainExecutorCs011SchedulableC0sWP +_$ss20DispatchMainExecutorCs010SchedulingC0sMc +_$ss20DispatchMainExecutorCs010SchedulingC0sWP _$ss20DispatchMainExecutorCs07RunLoopC0sMc _$ss20DispatchMainExecutorCs07RunLoopC0sWP _$ss20DispatchMainExecutorCs0bC0sMc @@ -952,8 +936,8 @@ _$ss26DispatchGlobalTaskExecutorCSchsMc _$ss26DispatchGlobalTaskExecutorCSchsWP _$ss26DispatchGlobalTaskExecutorCfD _$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sMc -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sWP +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1114,33 +1098,42 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp +_$ss5ClockP09CanonicalA0AB_sAATn +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTq _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTj _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTjTu _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq -_$ss5ClockP6traitss0A6TraitsVvgTj -_$ss5ClockP6traitss0A6TraitsVvgTq _$ss5ClockP7InstantAB_s0B8ProtocolTn -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTj -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTq -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTj -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTq -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTj -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTq -_$ss5ClockPsE6traitss0A6TraitsVvg -_$ss5ClockPsE6traitss0A6TraitsVvpMV -_$ss5ClockPsE7convert4from8DurationQzSgsAEV_tF -_$ss5ClockPsE7convert4froms8DurationVSgAEQz_tF -_$ss5ClockPsE7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lF +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF +_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF +_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF +_$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF +_$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKFTu _$ss5ClockPss010ContinuousA0VRszrlE10continuousADvgZ _$ss5ClockPss010SuspendingA0VRszrlE10suspendingADvgZ -_$ss5ClockPss8DurationVACRtzrlE7convert4fromADSgAD_tF _$ss5ClockTL _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlF _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlFTu diff --git a/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts b/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts index 62c6c49652893..faf82a577e56d 100644 --- a/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts +++ b/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts @@ -1,6 +1,7 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl +_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -25,6 +26,8 @@ _$sScEN _$sScEs5ErrorsMc _$sScF14isMainExecutorSbvgTj _$sScF14isMainExecutorSbvgTq +_$sScF20asSchedulingExecutors0bC0_pSgvgTj +_$sScF20asSchedulingExecutors0bC0_pSgvgTq _$sScF7enqueueyyScJFTj _$sScF7enqueueyyScJFTq _$sScF7enqueueyys11ExecutorJobVnFTj @@ -37,6 +40,8 @@ _$sScFsE14isMainExecutorSbvg _$sScFsE14isMainExecutorSbvpMV _$sScFsE18_isComplexEqualitySbvg _$sScFsE18_isComplexEqualitySbvpMV +_$sScFsE20asSchedulingExecutors0bC0_pSgvg +_$sScFsE20asSchedulingExecutors0bC0_pSgvpMV _$sScFsE7enqueueyyScJF _$sScFsE7enqueueyys11ExecutorJobVnF _$sScFsE7enqueueyys3JobVnF @@ -219,8 +224,8 @@ _$sScTss5NeverORszABRs_rlE15defaultExecutorSch_pvpZMV _$sScTss5NeverORszABRs_rlE17checkCancellationyyKFZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvgZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvpZMV -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvgZ -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvpZMV +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvgZ +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvpZMV _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZTu _$sScTss5NeverORszABRs_rlE5sleep5until9tolerance5clocky7InstantQyd___8DurationQyd__Sgqd__tYaKs5ClockRd__lFZ @@ -405,23 +410,6 @@ _$sSctN _$sSctSHsMc _$sSctSQsMc _$ss039_checkIllegalTaskLocalBindingWithinWithC5Group4file4lineySS_SutF -_$ss11ClockTraitsV10continuousABvgZ -_$ss11ClockTraitsV10continuousABvpZMV -_$ss11ClockTraitsV8rawValueABs6UInt32V_tcfC -_$ss11ClockTraitsV8rawValues6UInt32Vvg -_$ss11ClockTraitsV8rawValues6UInt32VvpMV -_$ss11ClockTraitsV8wallTimeABvgZ -_$ss11ClockTraitsV8wallTimeABvpZMV -_$ss11ClockTraitsV9monotonicABvgZ -_$ss11ClockTraitsV9monotonicABvpZMV -_$ss11ClockTraitsVMa -_$ss11ClockTraitsVMn -_$ss11ClockTraitsVN -_$ss11ClockTraitsVSQsMc -_$ss11ClockTraitsVSYsMc -_$ss11ClockTraitsVs10SetAlgebrasMc -_$ss11ClockTraitsVs25ExpressibleByArrayLiteralsMc -_$ss11ClockTraitsVs9OptionSetsMc _$ss11ExecutorJobV010withUnsafeA11PrivateData4bodyxxSwq_YKXE_tq_YKs5ErrorR_r0_lF _$ss11ExecutorJobV11descriptionSSvg _$ss11ExecutorJobV14LocalAllocatorV10deallocateyySpyxGlF @@ -433,6 +421,7 @@ _$ss11ExecutorJobV14LocalAllocatorV8allocate8capacitySwSi_tF _$ss11ExecutorJobV14LocalAllocatorVMa _$ss11ExecutorJobV14LocalAllocatorVMn _$ss11ExecutorJobV14LocalAllocatorVN +_$ss11ExecutorJobV16createTrampoline2toABx_tScFRzlF _$ss11ExecutorJobV4KindV13firstReservedADvgZ _$ss11ExecutorJobV4KindV13firstReservedADvpZMV _$ss11ExecutorJobV4KindV4taskADvgZ @@ -516,8 +505,6 @@ _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15ContinuousClockV6traitss0B6TraitsVvg -_$ss15ContinuousClockV6traitss0B6TraitsVvpMV _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV2eeoiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV3nowADvgZ @@ -566,8 +553,6 @@ _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15SuspendingClockV6traitss0B6TraitsVvg -_$ss15SuspendingClockV6traitss0B6TraitsVvpMV _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ _$ss15SuspendingClockV7InstantV1poiyA2D_s8DurationVtFZ _$ss15SuspendingClockV7InstantV1soiyA2D_s8DurationVtFZ @@ -619,6 +604,15 @@ _$ss16AsyncMapSequenceVMa _$ss16AsyncMapSequenceVMn _$ss16AsyncMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss16AsyncMapSequenceVyxq_GScisMc +_$ss18SchedulingExecutorMp +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorPScFTb +_$ss18SchedulingExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorTL _$ss19AsyncFilterSequenceV04makeA8IteratorAB0E0Vyx_GyF _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvg _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvpMV @@ -676,15 +670,6 @@ _$ss19DiscardingTaskGroupV9cancelAllyyF _$ss19DiscardingTaskGroupVMa _$ss19DiscardingTaskGroupVMn _$ss19DiscardingTaskGroupVN -_$ss19SchedulableExecutorMp -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorPScFTb -_$ss19SchedulableExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorTL _$ss19UnownedTaskExecutorV02asbC0Sch_pSgyF _$ss19UnownedTaskExecutorVyABxhcSchRzlufC _$ss20AsyncFlatMapSequenceV04makeA8IteratorAB0F0Vyxq__GyF @@ -718,14 +703,13 @@ _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc _$ss20DispatchMainExecutorC02isbC0Sbvg _$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvg -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvpMV _$ss20DispatchMainExecutorC13checkIsolatedyyF _$ss20DispatchMainExecutorC3runyyKFTj _$ss20DispatchMainExecutorC3runyyKFTq _$ss20DispatchMainExecutorC4stopyyFTj _$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlF +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq _$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF _$ss20DispatchMainExecutorCABycfC _$ss20DispatchMainExecutorCABycfCTj @@ -743,8 +727,8 @@ _$ss20DispatchMainExecutorCScfsMc _$ss20DispatchMainExecutorCScfsWP _$ss20DispatchMainExecutorCfD _$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs011SchedulableC0sMc -_$ss20DispatchMainExecutorCs011SchedulableC0sWP +_$ss20DispatchMainExecutorCs010SchedulingC0sMc +_$ss20DispatchMainExecutorCs010SchedulingC0sWP _$ss20DispatchMainExecutorCs07RunLoopC0sMc _$ss20DispatchMainExecutorCs07RunLoopC0sWP _$ss20DispatchMainExecutorCs0bC0sMc @@ -952,8 +936,8 @@ _$ss26DispatchGlobalTaskExecutorCSchsMc _$ss26DispatchGlobalTaskExecutorCSchsWP _$ss26DispatchGlobalTaskExecutorCfD _$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sMc -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sWP +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1114,33 +1098,42 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp +_$ss5ClockP09CanonicalA0AB_sAATn +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTq _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTj _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTjTu _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq -_$ss5ClockP6traitss0A6TraitsVvgTj -_$ss5ClockP6traitss0A6TraitsVvgTq _$ss5ClockP7InstantAB_s0B8ProtocolTn -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTj -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTq -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTj -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTq -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTj -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTq -_$ss5ClockPsE6traitss0A6TraitsVvg -_$ss5ClockPsE6traitss0A6TraitsVvpMV -_$ss5ClockPsE7convert4from8DurationQzSgsAEV_tF -_$ss5ClockPsE7convert4froms8DurationVSgAEQz_tF -_$ss5ClockPsE7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lF +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF +_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF +_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF +_$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF +_$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKFTu _$ss5ClockPss010ContinuousA0VRszrlE10continuousADvgZ _$ss5ClockPss010SuspendingA0VRszrlE10suspendingADvgZ -_$ss5ClockPss8DurationVACRtzrlE7convert4fromADSgAD_tF _$ss5ClockTL _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlF _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlFTu diff --git a/test/abi/Inputs/macOS/x86_64/concurrency/baseline b/test/abi/Inputs/macOS/x86_64/concurrency/baseline index 62c6c49652893..faf82a577e56d 100644 --- a/test/abi/Inputs/macOS/x86_64/concurrency/baseline +++ b/test/abi/Inputs/macOS/x86_64/concurrency/baseline @@ -1,6 +1,7 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl +_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -25,6 +26,8 @@ _$sScEN _$sScEs5ErrorsMc _$sScF14isMainExecutorSbvgTj _$sScF14isMainExecutorSbvgTq +_$sScF20asSchedulingExecutors0bC0_pSgvgTj +_$sScF20asSchedulingExecutors0bC0_pSgvgTq _$sScF7enqueueyyScJFTj _$sScF7enqueueyyScJFTq _$sScF7enqueueyys11ExecutorJobVnFTj @@ -37,6 +40,8 @@ _$sScFsE14isMainExecutorSbvg _$sScFsE14isMainExecutorSbvpMV _$sScFsE18_isComplexEqualitySbvg _$sScFsE18_isComplexEqualitySbvpMV +_$sScFsE20asSchedulingExecutors0bC0_pSgvg +_$sScFsE20asSchedulingExecutors0bC0_pSgvpMV _$sScFsE7enqueueyyScJF _$sScFsE7enqueueyys11ExecutorJobVnF _$sScFsE7enqueueyys3JobVnF @@ -219,8 +224,8 @@ _$sScTss5NeverORszABRs_rlE15defaultExecutorSch_pvpZMV _$sScTss5NeverORszABRs_rlE17checkCancellationyyKFZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvgZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvpZMV -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvgZ -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvpZMV +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvgZ +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvpZMV _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZTu _$sScTss5NeverORszABRs_rlE5sleep5until9tolerance5clocky7InstantQyd___8DurationQyd__Sgqd__tYaKs5ClockRd__lFZ @@ -405,23 +410,6 @@ _$sSctN _$sSctSHsMc _$sSctSQsMc _$ss039_checkIllegalTaskLocalBindingWithinWithC5Group4file4lineySS_SutF -_$ss11ClockTraitsV10continuousABvgZ -_$ss11ClockTraitsV10continuousABvpZMV -_$ss11ClockTraitsV8rawValueABs6UInt32V_tcfC -_$ss11ClockTraitsV8rawValues6UInt32Vvg -_$ss11ClockTraitsV8rawValues6UInt32VvpMV -_$ss11ClockTraitsV8wallTimeABvgZ -_$ss11ClockTraitsV8wallTimeABvpZMV -_$ss11ClockTraitsV9monotonicABvgZ -_$ss11ClockTraitsV9monotonicABvpZMV -_$ss11ClockTraitsVMa -_$ss11ClockTraitsVMn -_$ss11ClockTraitsVN -_$ss11ClockTraitsVSQsMc -_$ss11ClockTraitsVSYsMc -_$ss11ClockTraitsVs10SetAlgebrasMc -_$ss11ClockTraitsVs25ExpressibleByArrayLiteralsMc -_$ss11ClockTraitsVs9OptionSetsMc _$ss11ExecutorJobV010withUnsafeA11PrivateData4bodyxxSwq_YKXE_tq_YKs5ErrorR_r0_lF _$ss11ExecutorJobV11descriptionSSvg _$ss11ExecutorJobV14LocalAllocatorV10deallocateyySpyxGlF @@ -433,6 +421,7 @@ _$ss11ExecutorJobV14LocalAllocatorV8allocate8capacitySwSi_tF _$ss11ExecutorJobV14LocalAllocatorVMa _$ss11ExecutorJobV14LocalAllocatorVMn _$ss11ExecutorJobV14LocalAllocatorVN +_$ss11ExecutorJobV16createTrampoline2toABx_tScFRzlF _$ss11ExecutorJobV4KindV13firstReservedADvgZ _$ss11ExecutorJobV4KindV13firstReservedADvpZMV _$ss11ExecutorJobV4KindV4taskADvgZ @@ -516,8 +505,6 @@ _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15ContinuousClockV6traitss0B6TraitsVvg -_$ss15ContinuousClockV6traitss0B6TraitsVvpMV _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV2eeoiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV3nowADvgZ @@ -566,8 +553,6 @@ _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15SuspendingClockV6traitss0B6TraitsVvg -_$ss15SuspendingClockV6traitss0B6TraitsVvpMV _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ _$ss15SuspendingClockV7InstantV1poiyA2D_s8DurationVtFZ _$ss15SuspendingClockV7InstantV1soiyA2D_s8DurationVtFZ @@ -619,6 +604,15 @@ _$ss16AsyncMapSequenceVMa _$ss16AsyncMapSequenceVMn _$ss16AsyncMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss16AsyncMapSequenceVyxq_GScisMc +_$ss18SchedulingExecutorMp +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorPScFTb +_$ss18SchedulingExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorTL _$ss19AsyncFilterSequenceV04makeA8IteratorAB0E0Vyx_GyF _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvg _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvpMV @@ -676,15 +670,6 @@ _$ss19DiscardingTaskGroupV9cancelAllyyF _$ss19DiscardingTaskGroupVMa _$ss19DiscardingTaskGroupVMn _$ss19DiscardingTaskGroupVN -_$ss19SchedulableExecutorMp -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorPScFTb -_$ss19SchedulableExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorTL _$ss19UnownedTaskExecutorV02asbC0Sch_pSgyF _$ss19UnownedTaskExecutorVyABxhcSchRzlufC _$ss20AsyncFlatMapSequenceV04makeA8IteratorAB0F0Vyxq__GyF @@ -718,14 +703,13 @@ _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc _$ss20DispatchMainExecutorC02isbC0Sbvg _$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvg -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvpMV _$ss20DispatchMainExecutorC13checkIsolatedyyF _$ss20DispatchMainExecutorC3runyyKFTj _$ss20DispatchMainExecutorC3runyyKFTq _$ss20DispatchMainExecutorC4stopyyFTj _$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlF +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq _$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF _$ss20DispatchMainExecutorCABycfC _$ss20DispatchMainExecutorCABycfCTj @@ -743,8 +727,8 @@ _$ss20DispatchMainExecutorCScfsMc _$ss20DispatchMainExecutorCScfsWP _$ss20DispatchMainExecutorCfD _$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs011SchedulableC0sMc -_$ss20DispatchMainExecutorCs011SchedulableC0sWP +_$ss20DispatchMainExecutorCs010SchedulingC0sMc +_$ss20DispatchMainExecutorCs010SchedulingC0sWP _$ss20DispatchMainExecutorCs07RunLoopC0sMc _$ss20DispatchMainExecutorCs07RunLoopC0sWP _$ss20DispatchMainExecutorCs0bC0sMc @@ -952,8 +936,8 @@ _$ss26DispatchGlobalTaskExecutorCSchsMc _$ss26DispatchGlobalTaskExecutorCSchsWP _$ss26DispatchGlobalTaskExecutorCfD _$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sMc -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sWP +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1114,33 +1098,42 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp +_$ss5ClockP09CanonicalA0AB_sAATn +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTq _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTj _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTjTu _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq -_$ss5ClockP6traitss0A6TraitsVvgTj -_$ss5ClockP6traitss0A6TraitsVvgTq _$ss5ClockP7InstantAB_s0B8ProtocolTn -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTj -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTq -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTj -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTq -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTj -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTq -_$ss5ClockPsE6traitss0A6TraitsVvg -_$ss5ClockPsE6traitss0A6TraitsVvpMV -_$ss5ClockPsE7convert4from8DurationQzSgsAEV_tF -_$ss5ClockPsE7convert4froms8DurationVSgAEQz_tF -_$ss5ClockPsE7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lF +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF +_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF +_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF +_$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF +_$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKFTu _$ss5ClockPss010ContinuousA0VRszrlE10continuousADvgZ _$ss5ClockPss010SuspendingA0VRszrlE10suspendingADvgZ -_$ss5ClockPss8DurationVACRtzrlE7convert4fromADSgAD_tF _$ss5ClockTL _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlF _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlFTu diff --git a/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts b/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts index 62c6c49652893..faf82a577e56d 100644 --- a/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts +++ b/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts @@ -1,6 +1,7 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl +_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -25,6 +26,8 @@ _$sScEN _$sScEs5ErrorsMc _$sScF14isMainExecutorSbvgTj _$sScF14isMainExecutorSbvgTq +_$sScF20asSchedulingExecutors0bC0_pSgvgTj +_$sScF20asSchedulingExecutors0bC0_pSgvgTq _$sScF7enqueueyyScJFTj _$sScF7enqueueyyScJFTq _$sScF7enqueueyys11ExecutorJobVnFTj @@ -37,6 +40,8 @@ _$sScFsE14isMainExecutorSbvg _$sScFsE14isMainExecutorSbvpMV _$sScFsE18_isComplexEqualitySbvg _$sScFsE18_isComplexEqualitySbvpMV +_$sScFsE20asSchedulingExecutors0bC0_pSgvg +_$sScFsE20asSchedulingExecutors0bC0_pSgvpMV _$sScFsE7enqueueyyScJF _$sScFsE7enqueueyys11ExecutorJobVnF _$sScFsE7enqueueyys3JobVnF @@ -219,8 +224,8 @@ _$sScTss5NeverORszABRs_rlE15defaultExecutorSch_pvpZMV _$sScTss5NeverORszABRs_rlE17checkCancellationyyKFZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvgZ _$sScTss5NeverORszABRs_rlE17preferredExecutorSch_pSgvpZMV -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvgZ -_$sScTss5NeverORszABRs_rlE26currentSchedulableExecutors0cD0_pSgvpZMV +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvgZ +_$sScTss5NeverORszABRs_rlE25currentSchedulingExecutors0cD0_pSgvpZMV _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZ _$sScTss5NeverORszABRs_rlE5sleep11nanosecondsys6UInt64V_tYaKFZTu _$sScTss5NeverORszABRs_rlE5sleep5until9tolerance5clocky7InstantQyd___8DurationQyd__Sgqd__tYaKs5ClockRd__lFZ @@ -405,23 +410,6 @@ _$sSctN _$sSctSHsMc _$sSctSQsMc _$ss039_checkIllegalTaskLocalBindingWithinWithC5Group4file4lineySS_SutF -_$ss11ClockTraitsV10continuousABvgZ -_$ss11ClockTraitsV10continuousABvpZMV -_$ss11ClockTraitsV8rawValueABs6UInt32V_tcfC -_$ss11ClockTraitsV8rawValues6UInt32Vvg -_$ss11ClockTraitsV8rawValues6UInt32VvpMV -_$ss11ClockTraitsV8wallTimeABvgZ -_$ss11ClockTraitsV8wallTimeABvpZMV -_$ss11ClockTraitsV9monotonicABvgZ -_$ss11ClockTraitsV9monotonicABvpZMV -_$ss11ClockTraitsVMa -_$ss11ClockTraitsVMn -_$ss11ClockTraitsVN -_$ss11ClockTraitsVSQsMc -_$ss11ClockTraitsVSYsMc -_$ss11ClockTraitsVs10SetAlgebrasMc -_$ss11ClockTraitsVs25ExpressibleByArrayLiteralsMc -_$ss11ClockTraitsVs9OptionSetsMc _$ss11ExecutorJobV010withUnsafeA11PrivateData4bodyxxSwq_YKXE_tq_YKs5ErrorR_r0_lF _$ss11ExecutorJobV11descriptionSSvg _$ss11ExecutorJobV14LocalAllocatorV10deallocateyySpyxGlF @@ -433,6 +421,7 @@ _$ss11ExecutorJobV14LocalAllocatorV8allocate8capacitySwSi_tF _$ss11ExecutorJobV14LocalAllocatorVMa _$ss11ExecutorJobV14LocalAllocatorVMn _$ss11ExecutorJobV14LocalAllocatorVN +_$ss11ExecutorJobV16createTrampoline2toABx_tScFRzlF _$ss11ExecutorJobV4KindV13firstReservedADvgZ _$ss11ExecutorJobV4KindV13firstReservedADvpZMV _$ss11ExecutorJobV4KindV4taskADvgZ @@ -516,8 +505,6 @@ _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15ContinuousClockV6traitss0B6TraitsVvg -_$ss15ContinuousClockV6traitss0B6TraitsVvpMV _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV2eeoiySbAD_ADtFZ _$ss15ContinuousClockV7InstantV3nowADvgZ @@ -566,8 +553,6 @@ _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu -_$ss15SuspendingClockV6traitss0B6TraitsVvg -_$ss15SuspendingClockV6traitss0B6TraitsVvpMV _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ _$ss15SuspendingClockV7InstantV1poiyA2D_s8DurationVtFZ _$ss15SuspendingClockV7InstantV1soiyA2D_s8DurationVtFZ @@ -619,6 +604,15 @@ _$ss16AsyncMapSequenceVMa _$ss16AsyncMapSequenceVMn _$ss16AsyncMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss16AsyncMapSequenceVyxq_GScisMc +_$ss18SchedulingExecutorMp +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj +_$ss18SchedulingExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq +_$ss18SchedulingExecutorPScFTb +_$ss18SchedulingExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF +_$ss18SchedulingExecutorTL _$ss19AsyncFilterSequenceV04makeA8IteratorAB0E0Vyx_GyF _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvg _$ss19AsyncFilterSequenceV10isIncludedySb7ElementQzYacvpMV @@ -676,15 +670,6 @@ _$ss19DiscardingTaskGroupV9cancelAllyyF _$ss19DiscardingTaskGroupVMa _$ss19DiscardingTaskGroupVMn _$ss19DiscardingTaskGroupVN -_$ss19SchedulableExecutorMp -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTj -_$ss19SchedulableExecutorP7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lFTq -_$ss19SchedulableExecutorPScFTb -_$ss19SchedulableExecutorPsE7enqueue_2at9tolerance5clockys0B3JobVn_7InstantQyd__8DurationQyd__Sgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorPsE7enqueue_5after9tolerance5clockys0B3JobVn_8DurationQyd__AJSgqd__ts5ClockRd__lF -_$ss19SchedulableExecutorTL _$ss19UnownedTaskExecutorV02asbC0Sch_pSgyF _$ss19UnownedTaskExecutorVyABxhcSchRzlufC _$ss20AsyncFlatMapSequenceV04makeA8IteratorAB0F0Vyxq__GyF @@ -718,14 +703,13 @@ _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc _$ss20DispatchMainExecutorC02isbC0Sbvg _$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvg -_$ss20DispatchMainExecutorC13asSchedulables0eC0_pSgvpMV _$ss20DispatchMainExecutorC13checkIsolatedyyF _$ss20DispatchMainExecutorC3runyyKFTj _$ss20DispatchMainExecutorC3runyyKFTq _$ss20DispatchMainExecutorC4stopyyFTj _$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlF +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj +_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq _$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF _$ss20DispatchMainExecutorCABycfC _$ss20DispatchMainExecutorCABycfCTj @@ -743,8 +727,8 @@ _$ss20DispatchMainExecutorCScfsMc _$ss20DispatchMainExecutorCScfsWP _$ss20DispatchMainExecutorCfD _$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs011SchedulableC0sMc -_$ss20DispatchMainExecutorCs011SchedulableC0sWP +_$ss20DispatchMainExecutorCs010SchedulingC0sMc +_$ss20DispatchMainExecutorCs010SchedulingC0sWP _$ss20DispatchMainExecutorCs07RunLoopC0sMc _$ss20DispatchMainExecutorCs07RunLoopC0sWP _$ss20DispatchMainExecutorCs0bC0sMc @@ -952,8 +936,8 @@ _$ss26DispatchGlobalTaskExecutorCSchsMc _$ss26DispatchGlobalTaskExecutorCSchsWP _$ss26DispatchGlobalTaskExecutorCfD _$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sMc -_$ss26DispatchGlobalTaskExecutorCs011SchedulableD0sWP +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc +_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1114,33 +1098,42 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp +_$ss5ClockP09CanonicalA0AB_sAATn +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj +_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj +_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj +_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj +_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj +_$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTq _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTj _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTjTu _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq -_$ss5ClockP6traitss0A6TraitsVvgTj -_$ss5ClockP6traitss0A6TraitsVvgTq _$ss5ClockP7InstantAB_s0B8ProtocolTn -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTj -_$ss5ClockP7convert4from8DurationQzSgsAEV_tFTq -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTj -_$ss5ClockP7convert4froms8DurationVSgAEQz_tFTq -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTj -_$ss5ClockP7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lFTq -_$ss5ClockPsE6traitss0A6TraitsVvg -_$ss5ClockPsE6traitss0A6TraitsVvpMV -_$ss5ClockPsE7convert4from8DurationQzSgsAEV_tF -_$ss5ClockPsE7convert4froms8DurationVSgAEQz_tF -_$ss5ClockPsE7convert7instant4from7InstantQzSgAFQyd___qd__tsAARd__lF +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj +_$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg +_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF +_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF +_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF +_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF +_$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF +_$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF _$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKFTu _$ss5ClockPss010ContinuousA0VRszrlE10continuousADvgZ _$ss5ClockPss010SuspendingA0VRszrlE10suspendingADvgZ -_$ss5ClockPss8DurationVACRtzrlE7convert4fromADSgAD_tF _$ss5ClockTL _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlF _$ss6_first_5where7ElementQzSgx_SbADYaKXEtYaKSciRzlFTu From 3fceeba0ec9a1a13a561aeca3ac2ca2df8c4571a Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 24 Jun 2025 11:01:39 +0100 Subject: [PATCH 02/11] [Concurrency] Add implementations of run and enqueue for built-in clocks. The built-in clocks should have implementations of `run` and `enqueue`, to allow derived clocks to call those implementations. --- .../public/Concurrency/ContinuousClock.swift | 33 +++++++++++++++++++ .../public/Concurrency/SuspendingClock.swift | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/stdlib/public/Concurrency/ContinuousClock.swift b/stdlib/public/Concurrency/ContinuousClock.swift index df0d3385a57a9..d258528ec3561 100644 --- a/stdlib/public/Concurrency/ContinuousClock.swift +++ b/stdlib/public/Concurrency/ContinuousClock.swift @@ -211,3 +211,36 @@ extension ContinuousClock.Instant: InstantProtocol { rhs.duration(to: lhs) } } + +#if !$Embedded +@available(StdlibDeploymentTarget 6.2, *) +extension ContinuousClock { + + public func run(_ job: consuming ExecutorJob, + at instant: Instant, + tolerance: Duration?) { + guard let executor = Task.currentSchedulingExecutor else { + fatalError("no scheduling executor is available") + } + + executor.enqueue(job, at: instant, + tolerance: tolerance, + clock: self) + } + + public func enqueue(_ job: consuming ExecutorJob, + on executor: some Executor, + at instant: Instant, + tolerance: Duration?) { + if let schedulingExecutor = executor.asSchedulingExecutor { + schedulingExecutor.enqueue(job, at: instant, + tolerance: tolerance, + clock: self) + } else { + let trampoline = job.createTrampoline(to: executor) + run(trampoline, at: instant, tolerance: tolerance) + } + } + +} +#endif diff --git a/stdlib/public/Concurrency/SuspendingClock.swift b/stdlib/public/Concurrency/SuspendingClock.swift index b8ff0481f8406..df3ef9bc6029e 100644 --- a/stdlib/public/Concurrency/SuspendingClock.swift +++ b/stdlib/public/Concurrency/SuspendingClock.swift @@ -189,3 +189,36 @@ extension SuspendingClock.Instant: InstantProtocol { rhs.duration(to: lhs) } } + +#if !$Embedded +@available(StdlibDeploymentTarget 6.2, *) +extension SuspendingClock { + + public func run(_ job: consuming ExecutorJob, + at instant: Instant, + tolerance: Duration?) { + guard let executor = Task.currentSchedulingExecutor else { + fatalError("no scheduling executor is available") + } + + executor.enqueue(job, at: instant, + tolerance: tolerance, + clock: self) + } + + public func enqueue(_ job: consuming ExecutorJob, + on executor: some Executor, + at instant: Instant, + tolerance: Duration?) { + if let schedulingExecutor = executor.asSchedulingExecutor { + schedulingExecutor.enqueue(job, at: instant, + tolerance: tolerance, + clock: self) + } else { + let trampoline = job.createTrampoline(to: executor) + run(trampoline, at: instant, tolerance: tolerance) + } + } + +} +#endif From f83c7d8bddcd177a2d40be953dcc12681ac070c0 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 24 Jun 2025 11:11:30 +0100 Subject: [PATCH 03/11] [Concurrency] Remove canonicalization code. I don't think we actually need this. If you have a non-canonical (i.e. derived) clock, you can just implement `enqueue` and/or `run` and call those methods on the clock you're wrapping. --- stdlib/public/Concurrency/Clock.swift | 88 +------------------ .../Concurrency/CooperativeExecutor.swift | 16 ---- .../public/Concurrency/DispatchExecutor.swift | 33 +------ 3 files changed, 2 insertions(+), 135 deletions(-) diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index 6bad7350b5f38..3ef680e37a88e 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -34,7 +34,6 @@ import Swift public protocol Clock: Sendable { associatedtype Duration associatedtype Instant: InstantProtocol where Instant.Duration == Duration - associatedtype CanonicalClock: Clock = Self var now: Instant { get } var minimumResolution: Instant.Duration { get } @@ -76,58 +75,6 @@ public protocol Clock: Sendable { on executor: some Executor, at instant: Instant, tolerance: Duration?) #endif - - /// Obtain the equivalent, canonical clock, or `nil` if this clock - /// is already canonical. - /// - /// A non-canonical clock is a clock with some relationship to a base, - /// canonical, clock, to which it can be converted. - @available(StdlibDeploymentTarget 6.2, *) - var canonicalClock: CanonicalClock? { get } - - /// Convert an Instant to the canonical clock's equivalent Instant. - /// - /// Parameters: - /// - /// - instant: The `Instant` to convert. - /// - /// Returns: - /// - /// The equivalent `CanonicalClock.Instant`. - func convertToCanonical(instant: Instant) -> CanonicalClock.Instant - - /// Convert a Duration to the canonical clock's equivalent Duration. - /// - /// Parameters: - /// - /// - duration: The `Duration` to convert. - /// - /// Returns: - /// - /// The equivalent `CanonicalClock.Duration`. - func convertToCanonical(duration: Duration) -> CanonicalClock.Duration - - /// Convert an Instant to the canonical clock's equivalent Instant. - /// - /// Parameters: - /// - /// - instant: The `Instant` to convert, or `nil`. - /// - /// Returns: - /// - /// The equivalent `CanonicalClock.Instant`, or `nil` if `instant` was `nil`. - func maybeConvertToCanonical(instant: Instant?) -> CanonicalClock.Instant? - - /// Convert a Duration to the canonical clock's equivalent Duration. - /// - /// Parameters: - /// - /// - duration: The `Duration` to convert, or `nil`. - /// - /// Returns: - /// - /// The equivalent `CanonicalClock.Duration`, or `nil` if `duration` was `nil`. - func maybeConvertToCanonical(duration: Duration?) -> CanonicalClock.Duration? } extension Clock { @@ -150,40 +97,6 @@ extension Clock { } } -// Default implementations for canonicalization support -extension Clock where CanonicalClock == Self { - public var canonicalClock: CanonicalClock? { return nil } - - public func convertToCanonical(duration: Duration) -> CanonicalClock.Duration { - return duration - } - - public func convertToCanonical(instant: Instant) -> CanonicalClock.Instant { - return instant - } -} - -// nil-propagating versions of convertToCanonical() -extension Clock { - public func maybeConvertToCanonical(duration: Duration?) - -> CanonicalClock.Duration? - { - if let duration { - return convertToCanonical(duration: duration) - } - return nil - } - - public func maybeConvertToCanonical(instant: Instant?) - -> CanonicalClock.Instant? - { - if let instant { - return convertToCanonical(instant: instant) - } - return nil - } -} - @available(StdlibDeploymentTarget 5.7, *) extension Clock { /// Measure the elapsed time to execute a closure. @@ -258,6 +171,7 @@ extension Clock { enum _ClockID: Int32 { case continuous = 1 case suspending = 2 + case walltime = 3 } @available(StdlibDeploymentTarget 5.7, *) diff --git a/stdlib/public/Concurrency/CooperativeExecutor.swift b/stdlib/public/Concurrency/CooperativeExecutor.swift index 3a5e774f9da78..0ad6f723e7d68 100644 --- a/stdlib/public/Concurrency/CooperativeExecutor.swift +++ b/stdlib/public/Concurrency/CooperativeExecutor.swift @@ -202,22 +202,6 @@ extension CooperativeExecutor: SchedulingExecutor { after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { - // Convert the clock to its canonical equivalent, if any - if let canonical = clock.canonicalClock { - enqueueImpl(job, - after: clock.convertToCanonical(duration: delay), - tolerance: clock.maybeConvertToCanonical(duration: tolerance), - clock: canonical) - return - } - - enqueueImpl(job, after: delay, tolerance: tolerance, clock: clock) - } - - private func enqueueImpl(_ job: consuming ExecutorJob, - after delay: C.Duration, - tolerance: C.Duration? = nil, - clock: C) { // If it's a clock we know, get the duration to wait let duration: Duration if let _ = clock as? ContinuousClock { diff --git a/stdlib/public/Concurrency/DispatchExecutor.swift b/stdlib/public/Concurrency/DispatchExecutor.swift index 29a5a0d9a2dd5..76dad4c65e61a 100644 --- a/stdlib/public/Concurrency/DispatchExecutor.swift +++ b/stdlib/public/Concurrency/DispatchExecutor.swift @@ -105,6 +105,7 @@ public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor, enum DispatchClockID: CInt { case continuous = 1 case suspending = 2 + case walltime = 3 } fileprivate func clamp(_ components: (seconds: Int64, attoseconds: Int64)) @@ -153,38 +154,6 @@ fileprivate func _dispatchEnqueue( clock: C, executor: E, global: Bool -) { - // Convert the clock to its canonical equivalent, if any - if let canonical = clock.canonicalClock { - _dispatchEnqueueImpl( - job, - at: clock.convertToCanonical(instant: instant), - tolerance: clock.maybeConvertToCanonical(duration: tolerance), - clock: canonical, - executor: executor, - global: global - ) - return - } - - _dispatchEnqueueImpl( - job, - at: instant, - tolerance: tolerance, - clock: clock, - executor: executor, - global: global - ) -} - -@available(StdlibDeploymentTarget 6.2, *) -fileprivate func _dispatchEnqueueImpl( - _ job: consuming ExecutorJob, - at instant: C.Instant, - tolerance: C.Duration?, - clock: C, - executor: E, - global: Bool ) { // If it's a clock we know, convert it to something we can use; otherwise, // call the clock's `enqueue` function to schedule the enqueue of the job. From d5cf0bcc6c923406eaa5dfdc7f4833d07b7e9642 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 24 Jun 2025 13:05:15 +0100 Subject: [PATCH 04/11] [Concurrency] Fix CooperativeExecutor to not loop forever. If a job enqueues another job on the executor, we might never leave the inner `while` loop in the `run()` method. Fix this by taking the contents of the run queue and only running those jobs in the queue at the time we enter the inner loop. --- stdlib/public/Concurrency/CooperativeExecutor.swift | 3 ++- stdlib/public/Concurrency/PriorityQueue.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stdlib/public/Concurrency/CooperativeExecutor.swift b/stdlib/public/Concurrency/CooperativeExecutor.swift index 0ad6f723e7d68..3a6938f035d2c 100644 --- a/stdlib/public/Concurrency/CooperativeExecutor.swift +++ b/stdlib/public/Concurrency/CooperativeExecutor.swift @@ -248,7 +248,8 @@ extension CooperativeExecutor: RunLoopExecutor { #endif // Now run any queued jobs - while let job = runQueue.pop() { + var runQ = runQueue.take() + while let job = runQ.pop() { unsafe ExecutorJob(job).runSynchronously( on: self.asUnownedSerialExecutor() ) diff --git a/stdlib/public/Concurrency/PriorityQueue.swift b/stdlib/public/Concurrency/PriorityQueue.swift index 744c9c4c257a2..bfaa79c5cc17b 100644 --- a/stdlib/public/Concurrency/PriorityQueue.swift +++ b/stdlib/public/Concurrency/PriorityQueue.swift @@ -40,6 +40,15 @@ struct PriorityQueue { self.compare = compare } + /// Take the queue. + /// + /// This returns a copy of the queue, and empties the original. + mutating func take() -> PriorityQueue { + var q = PriorityQueue(compare: self.compare) + swap(&self, &q) + return q + } + /// Push an item onto the queue. /// /// Parameters: From f7f7ec41131f8e7f8e271af4ae52e9354dfc25ed Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 24 Jun 2025 13:06:48 +0100 Subject: [PATCH 05/11] [Concurrency] Add a couple of comments. Add some documentation comments to the Dispatch and CF executors, and update the comments for the allocation and private data APIs. --- stdlib/public/Concurrency/CFExecutor.swift | 2 ++ .../public/Concurrency/DispatchExecutor.swift | 2 ++ .../public/Concurrency/PartialAsyncTask.swift | 24 +++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/stdlib/public/Concurrency/CFExecutor.swift b/stdlib/public/Concurrency/CFExecutor.swift index 7a6a08918e3b5..aacff3e15f342 100644 --- a/stdlib/public/Concurrency/CFExecutor.swift +++ b/stdlib/public/Concurrency/CFExecutor.swift @@ -43,6 +43,7 @@ enum CoreFoundation { // .. Main Executor ............................................................ +/// A CFRunLoop-based main executor (Apple platforms only) @available(StdlibDeploymentTarget 6.2, *) public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { @@ -58,6 +59,7 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { // .. Task Executor ............................................................ +/// A `TaskExecutor` to match `CFMainExecutor` (Apple platforms only) @available(StdlibDeploymentTarget 6.2, *) public final class CFTaskExecutor: DispatchGlobalTaskExecutor, @unchecked Sendable { diff --git a/stdlib/public/Concurrency/DispatchExecutor.swift b/stdlib/public/Concurrency/DispatchExecutor.swift index 76dad4c65e61a..d532ec0667a56 100644 --- a/stdlib/public/Concurrency/DispatchExecutor.swift +++ b/stdlib/public/Concurrency/DispatchExecutor.swift @@ -23,6 +23,7 @@ import Swift // .. Main Executor ............................................................ +/// A Dispatch-based main executor. @available(StdlibDeploymentTarget 6.2, *) public class DispatchMainExecutor: RunLoopExecutor, SchedulingExecutor, @unchecked Sendable { @@ -75,6 +76,7 @@ extension DispatchMainExecutor: MainExecutor {} // .. Task Executor ............................................................ +/// A Dispatch-based `TaskExecutor` @available(StdlibDeploymentTarget 6.2, *) public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor, @unchecked Sendable { diff --git a/stdlib/public/Concurrency/PartialAsyncTask.swift b/stdlib/public/Concurrency/PartialAsyncTask.swift index 37992ee332793..6c1740638a354 100644 --- a/stdlib/public/Concurrency/PartialAsyncTask.swift +++ b/stdlib/public/Concurrency/PartialAsyncTask.swift @@ -318,7 +318,9 @@ public struct ExecutorJob: Sendable, ~Copyable { } /// Execute a closure, passing it the bounds of the executor private data - /// for the job. + /// for the job. The executor is responsible for ensuring that any resources + /// referenced from the private data area are cleared up prior to running the + /// job. /// /// Parameters: /// @@ -510,9 +512,8 @@ extension ExecutorJob { /// A job-local stack-disciplined allocator. /// /// This can be used to allocate additional data required by an - /// executor implementation; memory allocated in this manner will - /// be released automatically when the job is disposed of by the - /// runtime. + /// executor implementation; memory allocated in this manner must + /// be released by the executor before the job is executed. /// /// N.B. Because this allocator is stack disciplined, explicitly /// deallocating memory out-of-order will cause your program to abort. @@ -540,23 +541,20 @@ extension ExecutorJob { return unsafe UnsafeMutableBufferPointer(start: typedBase, count: capacity) } - /// Deallocate previously allocated memory. Note that the task - /// allocator is stack disciplined, so if you deallocate a block of - /// memory, all memory allocated after that block is also deallocated. + /// Deallocate previously allocated memory. You must do this in + /// reverse order of allocations, prior to running the job. public func deallocate(_ buffer: UnsafeMutableRawBufferPointer) { unsafe _jobDeallocate(context, buffer.baseAddress!) } - /// Deallocate previously allocated memory. Note that the task - /// allocator is stack disciplined, so if you deallocate a block of - /// memory, all memory allocated after that block is also deallocated. + /// Deallocate previously allocated memory. You must do this in + /// reverse order of allocations, prior to running the job. public func deallocate(_ pointer: UnsafeMutablePointer) { unsafe _jobDeallocate(context, UnsafeMutableRawPointer(pointer)) } - /// Deallocate previously allocated memory. Note that the task - /// allocator is stack disciplined, so if you deallocate a block of - /// memory, all memory allocated after that block is also deallocated. + /// Deallocate previously allocated memory. You must do this in + /// reverse order of allocations, prior to running the job. public func deallocate(_ buffer: UnsafeMutableBufferPointer) { unsafe _jobDeallocate(context, UnsafeMutableRawPointer(buffer.baseAddress!)) } From 46f09b02dabbcb84cc62428d2630309c315a2707 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 2 Jul 2025 14:23:44 +0100 Subject: [PATCH 06/11] [SILGen][Concurrency] Improve DefaultExecutorFactory lookup. Rather than just looking at top level in the module, start by searching the type marked as `@main`. This means that a library that provides a protocol or superclass that the `@main` type can conform to can specify an executor in a reasonable manner. --- lib/SILGen/SILGen.cpp | 31 +++++++++++++- .../Runtime/custom_main_executor.swift | 40 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp index 148a90ffa3f2f..4b25cbbdd0f9c 100644 --- a/lib/SILGen/SILGen.cpp +++ b/lib/SILGen/SILGen.cpp @@ -527,7 +527,36 @@ FuncDecl *SILGenModule::getExit() { Type SILGenModule::getConfiguredExecutorFactory() { auto &ctx = getASTContext(); - // Look in the main module for a typealias + // First look in the @main struct, if any + NominalTypeDecl *mainType = ctx.MainModule->getMainTypeDecl(); + if (mainType) { + SmallVector decls; + auto identifier = ctx.getIdentifier("DefaultExecutorFactory"); + mainType->lookupQualified(mainType, + DeclNameRef(identifier), + SourceLoc(), + NL_RemoveNonVisible | NL_RemoveOverridden + | NL_OnlyTypes | NL_ProtocolMembers, + decls); + for (auto decl : decls) { + TypeDecl *typeDecl = dyn_cast(decl); + if (typeDecl) { + if (auto *nominalDecl = dyn_cast(typeDecl)) { + return nominalDecl->getDeclaredType(); + } + + if (isa(typeDecl)) { + // We ignore associatedtype declarations; those with a default will + // turn into a `typealias` instead. + continue; + } + + return typeDecl->getDeclaredInterfaceType(); + } + } + } + + // Failing that, look at the top level Type factory = ctx.getNamedSwiftType(ctx.MainModule, "DefaultExecutorFactory"); // If we don't find it, fall back to _Concurrency.PlatformExecutorFactory diff --git a/test/Concurrency/Runtime/custom_main_executor.swift b/test/Concurrency/Runtime/custom_main_executor.swift index 08e9b8f7ce64e..6966d21cabef8 100644 --- a/test/Concurrency/Runtime/custom_main_executor.swift +++ b/test/Concurrency/Runtime/custom_main_executor.swift @@ -1,3 +1,8 @@ +// RUN: %target-run-simple-swift(-DTOPLEVEL_FACTORY -Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s +// RUN: %target-run-simple-swift(-DPROTOCOL_FACTORY -Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s +// RUN: %target-run-simple-swift(-DPROTOCOL_FACTORY_OVERRIDDEN -Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s +// RUN: %target-run-simple-swift(-DPROTOCOL_FACTORY_DEFAULT -Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s +// RUN: %target-run-simple-swift(-DPROTOCOL_FACTORY_DEFAULT2 -Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s // RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -g %import-libdispatch -parse-as-library) | %FileCheck %s // REQUIRES: concurrency @@ -13,7 +18,9 @@ import StdlibUnittest import Synchronization +#if TOPLEVEL_FACTORY typealias DefaultExecutorFactory = SimpleExecutorFactory +#endif struct SimpleExecutorFactory: ExecutorFactory { public static var mainExecutor: any MainExecutor { @@ -26,6 +33,15 @@ struct SimpleExecutorFactory: ExecutorFactory { } } +struct FatalExecutorFactory: ExecutorFactory { + public static var mainExecutor: any MainExecutor { + fatalError("mainExecutor called on FatalExecutorFactory") + } + public static var defaultExecutor: any TaskExecutor { + fatalError("taskExecutor called on FatalExecutorFactory") + } +} + @available(SwiftStdlib 6.2, *) final class SimpleMainExecutor: MainExecutor, @unchecked Sendable { public var isRunning: Bool = false @@ -74,8 +90,30 @@ func myAsyncFunction() async { print("Hello World") } +protocol AppProtocol { + #if PROTOCOL_FACTORY + associatedtype DefaultExecutorFactory + #endif + #if PROTOCOL_FACTORY_DEFAULT + associatedtype DefaultExecutorFactory = SimpleExecutorFactory + #endif + #if PROTOCOL_FACTORY_DEFAULT2 || PROTOCOL_FACTORY_OVERRIDDEN + associatedtype DefaultExecutorFactory = FatalExecutorFactory + #endif +} + +#if PROTOCOL_FACTORY || PROTOCOL_FACTORY_DEFAULT2 +extension AppProtocol { + typealias DefaultExecutorFactory = SimpleExecutorFactory +} +#endif + @available(SwiftStdlib 6.2, *) -@main struct Main { +@main struct Main: AppProtocol { + #if !TOPLEVEL_FACTORY && !PROTOCOL_FACTORY && !PROTOCOL_FACTORY_DEFAULT && !PROTOCOL_FACTORY_DEFAULT2 + typealias DefaultExecutorFactory = SimpleExecutorFactory + #endif + static func main() async { print("Hello") await myAsyncFunction() From cc5aa9bd7f1c7ca72ca51c74ad52c7a57fe5399c Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 2 Jul 2025 15:10:32 +0100 Subject: [PATCH 07/11] [Concurrency] Don't expose Dispatch or CF executors directly. Also add `final` to the `CooperativeExecutor` declaration. --- stdlib/public/Concurrency/CFExecutor.swift | 6 +++--- stdlib/public/Concurrency/CooperativeExecutor.swift | 2 +- stdlib/public/Concurrency/DispatchExecutor.swift | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/public/Concurrency/CFExecutor.swift b/stdlib/public/Concurrency/CFExecutor.swift index aacff3e15f342..067cd94991904 100644 --- a/stdlib/public/Concurrency/CFExecutor.swift +++ b/stdlib/public/Concurrency/CFExecutor.swift @@ -45,7 +45,7 @@ enum CoreFoundation { /// A CFRunLoop-based main executor (Apple platforms only) @available(StdlibDeploymentTarget 6.2, *) -public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { +final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { override public func run() throws { CoreFoundation.CFRunLoopRun() @@ -61,8 +61,8 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { /// A `TaskExecutor` to match `CFMainExecutor` (Apple platforms only) @available(StdlibDeploymentTarget 6.2, *) -public final class CFTaskExecutor: DispatchGlobalTaskExecutor, - @unchecked Sendable { +final class CFTaskExecutor: DispatchGlobalTaskExecutor, + @unchecked Sendable { } diff --git a/stdlib/public/Concurrency/CooperativeExecutor.swift b/stdlib/public/Concurrency/CooperativeExecutor.swift index 3a6938f035d2c..c8e33e3e78116 100644 --- a/stdlib/public/Concurrency/CooperativeExecutor.swift +++ b/stdlib/public/Concurrency/CooperativeExecutor.swift @@ -100,7 +100,7 @@ extension ExecutorJob { /// A co-operative executor that can be used as the main executor or as a /// task executor. @available(StdlibDeploymentTarget 6.2, *) -class CooperativeExecutor: Executor, @unchecked Sendable { +final class CooperativeExecutor: Executor, @unchecked Sendable { var runQueue: PriorityQueue #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY var waitQueue: PriorityQueue diff --git a/stdlib/public/Concurrency/DispatchExecutor.swift b/stdlib/public/Concurrency/DispatchExecutor.swift index d532ec0667a56..0910848ccd96b 100644 --- a/stdlib/public/Concurrency/DispatchExecutor.swift +++ b/stdlib/public/Concurrency/DispatchExecutor.swift @@ -25,8 +25,8 @@ import Swift /// A Dispatch-based main executor. @available(StdlibDeploymentTarget 6.2, *) -public class DispatchMainExecutor: RunLoopExecutor, SchedulingExecutor, - @unchecked Sendable { +class DispatchMainExecutor: RunLoopExecutor, SchedulingExecutor, + @unchecked Sendable { var threaded = false public init() {} @@ -78,8 +78,8 @@ extension DispatchMainExecutor: MainExecutor {} /// A Dispatch-based `TaskExecutor` @available(StdlibDeploymentTarget 6.2, *) -public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor, - @unchecked Sendable { +class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor, + @unchecked Sendable { public init() {} public func enqueue(_ job: consuming ExecutorJob) { From eb7bd9ea01b3ccedd1b1d8dfce2a5b1f812af7fe Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 4 Jul 2025 08:54:43 +0100 Subject: [PATCH 08/11] [Concurrency] Update documentation comment formatting. Some formatting fixes for the doc comments. --- stdlib/public/Concurrency/Clock.swift | 18 ++++----- stdlib/public/Concurrency/Executor.swift | 38 +++++++++---------- .../public/Concurrency/PartialAsyncTask.swift | 16 ++++---- stdlib/public/Concurrency/PriorityQueue.swift | 34 ++++++++--------- 4 files changed, 52 insertions(+), 54 deletions(-) diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index 3ef680e37a88e..d75bb4d098732 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -44,11 +44,11 @@ public protocol Clock: Sendable { /// Run the given job on an unspecified executor at some point /// after the given instant. /// - /// Parameters: + /// - Parameters: /// - /// - job: The job we wish to run - /// - at instant: The time at which we would like it to run. - /// - tolerance: The ideal maximum delay we are willing to tolerate. + /// - job: The job we wish to run + /// - instant: The time at which we would like it to run. + /// - tolerance: The ideal maximum delay we are willing to tolerate. /// @available(StdlibDeploymentTarget 6.2, *) func run(_ job: consuming ExecutorJob, @@ -63,12 +63,12 @@ public protocol Clock: Sendable { /// on, it can short-circuit this behaviour and directly use `run` with /// the original job. /// - /// Parameters: + /// - Parameters: /// - /// - job: The job we wish to run - /// - on executor: The executor on which we would like it to run. - /// - at instant: The time at which we would like it to run. - /// - tolerance: The ideal maximum delay we are willing to tolerate. + /// - job: The job we wish to run + /// - executor: The executor on which we would like it to run. + /// - instant: The time at which we would like it to run. + /// - tolerance: The ideal maximum delay we are willing to tolerate. /// @available(StdlibDeploymentTarget 6.2, *) func enqueue(_ job: consuming ExecutorJob, diff --git a/stdlib/public/Concurrency/Executor.swift b/stdlib/public/Concurrency/Executor.swift index ecda65b88db18..32c93b9ccdf91 100644 --- a/stdlib/public/Concurrency/Executor.swift +++ b/stdlib/public/Concurrency/Executor.swift @@ -65,15 +65,15 @@ public protocol SchedulingExecutor: Executor { /// the default implementation for the other will then call the one /// you have implemented. /// - /// Parameters: - /// - /// - job: The job to schedule. - /// - after: A `Duration` specifying the time after which the job - /// is to run. The job will not be executed before this - /// time has elapsed. - /// - tolerance: The maximum additional delay permissible before the - /// job is executed. `nil` means no limit. - /// - clock: The clock used for the delay. + /// - Parameters: + /// + /// - job: The job to schedule. + /// - after: A `Duration` specifying the time after which the job + /// is to run. The job will not be executed before this + /// time has elapsed. + /// - tolerance: The maximum additional delay permissible before the + /// job is executed. `nil` means no limit. + /// - clock: The clock used for the delay. @available(StdlibDeploymentTarget 6.2, *) func enqueue(_ job: consuming ExecutorJob, after delay: C.Duration, @@ -86,14 +86,14 @@ public protocol SchedulingExecutor: Executor { /// the default implementation for the other will then call the one /// you have implemented. /// - /// Parameters: + /// - Parameters: /// - /// - job: The job to schedule. - /// - at: The `Instant` at which the job should run. The job - /// will not be executed before this time. - /// - tolerance: The maximum additional delay permissible before the - /// job is executed. `nil` means no limit. - /// - clock: The clock used for the delay.. + /// - job: The job to schedule. + /// - at: The `Instant` at which the job should run. The job + /// will not be executed before this time. + /// - tolerance: The maximum additional delay permissible before the + /// job is executed. `nil` means no limit. + /// - clock: The clock used for the delay.. @available(StdlibDeploymentTarget 6.2, *) func enqueue(_ job: consuming ExecutorJob, at instant: C.Instant, @@ -557,10 +557,10 @@ public protocol RunLoopExecutor: Executor { /// it unless you *know* that it is supported. The default implementation /// generates a fatal error. /// - /// Parameters: + /// - Parameters: /// - /// - condition: A closure that returns `true` if the run loop should - /// stop. + /// - condition: A closure that returns `true` if the run loop should + /// stop. func runUntil(_ condition: () -> Bool) throws /// Signal to the run loop to stop running and return. diff --git a/stdlib/public/Concurrency/PartialAsyncTask.swift b/stdlib/public/Concurrency/PartialAsyncTask.swift index 6c1740638a354..be23f9b3e6784 100644 --- a/stdlib/public/Concurrency/PartialAsyncTask.swift +++ b/stdlib/public/Concurrency/PartialAsyncTask.swift @@ -322,11 +322,11 @@ public struct ExecutorJob: Sendable, ~Copyable { /// referenced from the private data area are cleared up prior to running the /// job. /// - /// Parameters: + /// - Parameters: /// - /// - body: The closure to execute. + /// - body: The closure to execute. /// - /// Returns the result of executing the closure. + /// - Returns: The result of executing the closure. @available(StdlibDeploymentTarget 6.2, *) public func withUnsafeExecutorPrivateData(body: (UnsafeMutableRawBufferPointer) throws(E) -> R) throws(E) -> R { let base = _jobGetExecutorPrivateData(self.context) @@ -462,14 +462,12 @@ extension ExecutorJob { /// This is useful in conjunction with the `Clock.run()` API, which /// runs a job on an unspecified executor. /// - /// Parameters: + /// - Parameters: /// - /// - to executor: The `Executor` on which it should be enqueued. + /// - executor: The `Executor` on which it should be enqueued. /// - /// Returns: - /// - /// A new ExecutorJob that will enqueue the specified job on the specified - /// executor. + /// - Returns: A new ExecutorJob that will enqueue the specified job on the + /// specified executor. @available(StdlibDeploymentTarget 6.2, *) public func createTrampoline(to executor: some Executor) -> ExecutorJob { let flags = taskCreateFlags( diff --git a/stdlib/public/Concurrency/PriorityQueue.swift b/stdlib/public/Concurrency/PriorityQueue.swift index bfaa79c5cc17b..7a23ad5f9f6fc 100644 --- a/stdlib/public/Concurrency/PriorityQueue.swift +++ b/stdlib/public/Concurrency/PriorityQueue.swift @@ -31,10 +31,10 @@ struct PriorityQueue { /// is `>`, it will be a max-queue, while if the comparison function /// is `<`, it will be a min-queue. /// - /// Parameters: + /// - Parameters: /// - /// - compare: A closure that takes two arguments of type T, and - /// returns true if some condition holds. + /// - compare: A closure that takes two arguments of type T, and + /// returns true if some condition holds. /// init(compare: @escaping (borrowing T, borrowing T) -> Bool) { self.compare = compare @@ -51,9 +51,9 @@ struct PriorityQueue { /// Push an item onto the queue. /// - /// Parameters: + /// - Parameters: /// - /// - _ value: The item to push onto the queue. + /// - value: The item to push onto the queue. /// mutating func push(_ value: T) { storage.append(value) @@ -74,13 +74,13 @@ struct PriorityQueue { /// item in the queue. If the comparison function is `<`, it will /// return the smallest. /// - /// Parameters: + /// - Parameters: /// - /// - when: A closure that allows code to test the top item before - /// popping. + /// - when: A closure that allows code to test the top item before + /// popping. /// - /// Returns: The next item in the queue, following the comparison - /// rule. + /// - Returns: The next item in the queue, following the comparison + /// rule. /// mutating func pop(when condition: (borrowing T) -> Bool) -> T? { if storage.isEmpty { @@ -103,8 +103,8 @@ struct PriorityQueue { /// item in the queue. If the comparison function is `<`, it will /// return the smallest. /// - /// Returns: The next item in the queue, following the comparison - /// rule. + /// - Returns: The next item in the queue, following the comparison + /// rule. /// mutating func pop() -> T? { if storage.isEmpty { @@ -126,9 +126,9 @@ struct PriorityQueue { /// /// This is used when pushing items onto the queue. /// - /// Parameters: + /// - Parameters: /// - /// - ndx: The index at which to start. + /// - ndx: The index at which to start. /// private mutating func upHeap(ndx: Int) { var theNdx = ndx @@ -153,11 +153,11 @@ struct PriorityQueue { /// /// This is used when popping items from the queue. /// - /// Parameters: + /// - Parameters: /// - /// - ndx: The index at which to start. + /// - ndx: The index at which to start. /// - private mutating func downHeap(ndx: Int) { + private mutating func downHeap(ndx: Int) { var theNdx = ndx while true { let leftNdx = 2 * theNdx From 848bb6dd071ae7377b1b43edcd952ff35236376e Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 14 Jul 2025 12:17:55 +0100 Subject: [PATCH 09/11] [Test][Concurrency] Fix a few test failures. I'd missed some canonical clock code in the Concurrency tests. Also, update the ABI baselines again. --- .../async_task_executor_nsobject.swift | 9 -- test/Concurrency/Runtime/sleep_executor.swift | 9 -- .../Inputs/macOS/arm64/concurrency/baseline | 99 +------------------ .../macOS/arm64/concurrency/baseline-asserts | 99 +------------------ .../Inputs/macOS/x86_64/concurrency/baseline | 99 +------------------ .../macOS/x86_64/concurrency/baseline-asserts | 99 +------------------ 6 files changed, 16 insertions(+), 398 deletions(-) diff --git a/test/Concurrency/Runtime/async_task_executor_nsobject.swift b/test/Concurrency/Runtime/async_task_executor_nsobject.swift index 827b76a047bfe..6f185dd92812a 100644 --- a/test/Concurrency/Runtime/async_task_executor_nsobject.swift +++ b/test/Concurrency/Runtime/async_task_executor_nsobject.swift @@ -34,15 +34,6 @@ final class NSQueueTaskExecutor: NSData, TaskExecutor, SchedulingExecutor, @unch after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { - // Convert the clock to its canonical equivalent, if any - if let canonical = clock.canonicalClock { - enqueue(_job, - after: clock.convertToCanonical(duration: delay), - tolerance: clock.maybeConvertToCanonical(duration: tolerance), - clock: canonical) - return - } - // Convert to `Swift.Duration` let duration = delay as! Swift.Duration diff --git a/test/Concurrency/Runtime/sleep_executor.swift b/test/Concurrency/Runtime/sleep_executor.swift index d3abe6cb8b9db..daeb25a44ed02 100644 --- a/test/Concurrency/Runtime/sleep_executor.swift +++ b/test/Concurrency/Runtime/sleep_executor.swift @@ -37,15 +37,6 @@ final class TestExecutor: TaskExecutor, SchedulingExecutor, @unchecked Sendable after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { - // Convert the clock to its canonical equivalent, if any - if let canonical = clock.canonicalClock { - enqueue(_job, - after: clock.convertToCanonical(duration: delay), - tolerance: clock.maybeConvertToCanonical(duration: tolerance), - clock: canonical) - return - } - // Convert to `Swift.Duration` let duration = delay as! Swift.Duration diff --git a/test/abi/Inputs/macOS/arm64/concurrency/baseline b/test/abi/Inputs/macOS/arm64/concurrency/baseline index faf82a577e56d..9f91995fd1839 100644 --- a/test/abi/Inputs/macOS/arm64/concurrency/baseline +++ b/test/abi/Inputs/macOS/arm64/concurrency/baseline @@ -1,7 +1,6 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl -_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -478,31 +477,12 @@ _$ss12MainExecutorTL _$ss13_runAsyncMainyyyyYaKcF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lFTu -_$ss14CFMainExecutorC3runyyKF -_$ss14CFMainExecutorC4stopyyF -_$ss14CFMainExecutorCABycfC -_$ss14CFMainExecutorCABycfc -_$ss14CFMainExecutorCMa -_$ss14CFMainExecutorCMm -_$ss14CFMainExecutorCMn -_$ss14CFMainExecutorCMo -_$ss14CFMainExecutorCN -_$ss14CFMainExecutorCfD -_$ss14CFMainExecutorCfd -_$ss14CFTaskExecutorCABycfC -_$ss14CFTaskExecutorCABycfc -_$ss14CFTaskExecutorCMa -_$ss14CFTaskExecutorCMm -_$ss14CFTaskExecutorCMn -_$ss14CFTaskExecutorCMo -_$ss14CFTaskExecutorCN -_$ss14CFTaskExecutorCfD -_$ss14CFTaskExecutorCfd _$ss15ContinuousClockV17minimumResolutions8DurationVvg _$ss15ContinuousClockV17minimumResolutions8DurationVvpMV _$ss15ContinuousClockV3nowAB7InstantVvg _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV +_$ss15ContinuousClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ @@ -524,6 +504,7 @@ _$ss15ContinuousClockV7InstantVSLsMc _$ss15ContinuousClockV7InstantVSQsMc _$ss15ContinuousClockV7InstantVSesMc _$ss15ContinuousClockV7InstantVs0C8ProtocolsMc +_$ss15ContinuousClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15ContinuousClockVABycfC _$ss15ContinuousClockVMa _$ss15ContinuousClockVMn @@ -551,6 +532,7 @@ _$ss15SuspendingClockV17minimumResolutions8DurationVvpMV _$ss15SuspendingClockV3nowAB7InstantVvg _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV +_$ss15SuspendingClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ @@ -577,6 +559,7 @@ _$ss15SuspendingClockV7InstantVSLsMc _$ss15SuspendingClockV7InstantVSQsMc _$ss15SuspendingClockV7InstantVSesMc _$ss15SuspendingClockV7InstantVs0C8ProtocolsMc +_$ss15SuspendingClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15SuspendingClockVABycfC _$ss15SuspendingClockVMa _$ss15SuspendingClockVMn @@ -701,38 +684,6 @@ _$ss20AsyncFlatMapSequenceVMa _$ss20AsyncFlatMapSequenceVMn _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc -_$ss20DispatchMainExecutorC02isbC0Sbvg -_$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13checkIsolatedyyF -_$ss20DispatchMainExecutorC3runyyKFTj -_$ss20DispatchMainExecutorC3runyyKFTq -_$ss20DispatchMainExecutorC4stopyyFTj -_$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF -_$ss20DispatchMainExecutorCABycfC -_$ss20DispatchMainExecutorCABycfCTj -_$ss20DispatchMainExecutorCABycfCTq -_$ss20DispatchMainExecutorCABycfc -_$ss20DispatchMainExecutorCMa -_$ss20DispatchMainExecutorCMm -_$ss20DispatchMainExecutorCMn -_$ss20DispatchMainExecutorCMo -_$ss20DispatchMainExecutorCMu -_$ss20DispatchMainExecutorCN -_$ss20DispatchMainExecutorCScFsMc -_$ss20DispatchMainExecutorCScFsWP -_$ss20DispatchMainExecutorCScfsMc -_$ss20DispatchMainExecutorCScfsWP -_$ss20DispatchMainExecutorCfD -_$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs010SchedulingC0sMc -_$ss20DispatchMainExecutorCs010SchedulingC0sWP -_$ss20DispatchMainExecutorCs07RunLoopC0sMc -_$ss20DispatchMainExecutorCs07RunLoopC0sWP -_$ss20DispatchMainExecutorCs0bC0sMc -_$ss20DispatchMainExecutorCs0bC0sWP _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lF _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lFTu _$ss21withUnsafeCurrentTask4bodyxxSctSgKXE_tKlF @@ -913,31 +864,6 @@ _$ss25UnimplementedTaskExecutorCSchsMc _$ss25UnimplementedTaskExecutorCSchsWP _$ss25UnimplementedTaskExecutorCfD _$ss25UnimplementedTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTj -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTq -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvpMV -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTj -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTq -_$ss26DispatchGlobalTaskExecutorCABycfC -_$ss26DispatchGlobalTaskExecutorCABycfCTj -_$ss26DispatchGlobalTaskExecutorCABycfCTq -_$ss26DispatchGlobalTaskExecutorCABycfc -_$ss26DispatchGlobalTaskExecutorCMa -_$ss26DispatchGlobalTaskExecutorCMm -_$ss26DispatchGlobalTaskExecutorCMn -_$ss26DispatchGlobalTaskExecutorCMo -_$ss26DispatchGlobalTaskExecutorCMu -_$ss26DispatchGlobalTaskExecutorCN -_$ss26DispatchGlobalTaskExecutorCScFsMc -_$ss26DispatchGlobalTaskExecutorCScFsWP -_$ss26DispatchGlobalTaskExecutorCSchsMc -_$ss26DispatchGlobalTaskExecutorCSchsWP -_$ss26DispatchGlobalTaskExecutorCfD -_$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1098,19 +1024,8 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp -_$ss5ClockP09CanonicalA0AB_sAATn -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq _$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj @@ -1121,12 +1036,6 @@ _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq _$ss5ClockP7InstantAB_s0B8ProtocolTn _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF -_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF -_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF _$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF _$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF diff --git a/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts b/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts index faf82a577e56d..9f91995fd1839 100644 --- a/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts +++ b/test/abi/Inputs/macOS/arm64/concurrency/baseline-asserts @@ -1,7 +1,6 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl -_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -478,31 +477,12 @@ _$ss12MainExecutorTL _$ss13_runAsyncMainyyyyYaKcF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lFTu -_$ss14CFMainExecutorC3runyyKF -_$ss14CFMainExecutorC4stopyyF -_$ss14CFMainExecutorCABycfC -_$ss14CFMainExecutorCABycfc -_$ss14CFMainExecutorCMa -_$ss14CFMainExecutorCMm -_$ss14CFMainExecutorCMn -_$ss14CFMainExecutorCMo -_$ss14CFMainExecutorCN -_$ss14CFMainExecutorCfD -_$ss14CFMainExecutorCfd -_$ss14CFTaskExecutorCABycfC -_$ss14CFTaskExecutorCABycfc -_$ss14CFTaskExecutorCMa -_$ss14CFTaskExecutorCMm -_$ss14CFTaskExecutorCMn -_$ss14CFTaskExecutorCMo -_$ss14CFTaskExecutorCN -_$ss14CFTaskExecutorCfD -_$ss14CFTaskExecutorCfd _$ss15ContinuousClockV17minimumResolutions8DurationVvg _$ss15ContinuousClockV17minimumResolutions8DurationVvpMV _$ss15ContinuousClockV3nowAB7InstantVvg _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV +_$ss15ContinuousClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ @@ -524,6 +504,7 @@ _$ss15ContinuousClockV7InstantVSLsMc _$ss15ContinuousClockV7InstantVSQsMc _$ss15ContinuousClockV7InstantVSesMc _$ss15ContinuousClockV7InstantVs0C8ProtocolsMc +_$ss15ContinuousClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15ContinuousClockVABycfC _$ss15ContinuousClockVMa _$ss15ContinuousClockVMn @@ -551,6 +532,7 @@ _$ss15SuspendingClockV17minimumResolutions8DurationVvpMV _$ss15SuspendingClockV3nowAB7InstantVvg _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV +_$ss15SuspendingClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ @@ -577,6 +559,7 @@ _$ss15SuspendingClockV7InstantVSLsMc _$ss15SuspendingClockV7InstantVSQsMc _$ss15SuspendingClockV7InstantVSesMc _$ss15SuspendingClockV7InstantVs0C8ProtocolsMc +_$ss15SuspendingClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15SuspendingClockVABycfC _$ss15SuspendingClockVMa _$ss15SuspendingClockVMn @@ -701,38 +684,6 @@ _$ss20AsyncFlatMapSequenceVMa _$ss20AsyncFlatMapSequenceVMn _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc -_$ss20DispatchMainExecutorC02isbC0Sbvg -_$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13checkIsolatedyyF -_$ss20DispatchMainExecutorC3runyyKFTj -_$ss20DispatchMainExecutorC3runyyKFTq -_$ss20DispatchMainExecutorC4stopyyFTj -_$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF -_$ss20DispatchMainExecutorCABycfC -_$ss20DispatchMainExecutorCABycfCTj -_$ss20DispatchMainExecutorCABycfCTq -_$ss20DispatchMainExecutorCABycfc -_$ss20DispatchMainExecutorCMa -_$ss20DispatchMainExecutorCMm -_$ss20DispatchMainExecutorCMn -_$ss20DispatchMainExecutorCMo -_$ss20DispatchMainExecutorCMu -_$ss20DispatchMainExecutorCN -_$ss20DispatchMainExecutorCScFsMc -_$ss20DispatchMainExecutorCScFsWP -_$ss20DispatchMainExecutorCScfsMc -_$ss20DispatchMainExecutorCScfsWP -_$ss20DispatchMainExecutorCfD -_$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs010SchedulingC0sMc -_$ss20DispatchMainExecutorCs010SchedulingC0sWP -_$ss20DispatchMainExecutorCs07RunLoopC0sMc -_$ss20DispatchMainExecutorCs07RunLoopC0sWP -_$ss20DispatchMainExecutorCs0bC0sMc -_$ss20DispatchMainExecutorCs0bC0sWP _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lF _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lFTu _$ss21withUnsafeCurrentTask4bodyxxSctSgKXE_tKlF @@ -913,31 +864,6 @@ _$ss25UnimplementedTaskExecutorCSchsMc _$ss25UnimplementedTaskExecutorCSchsWP _$ss25UnimplementedTaskExecutorCfD _$ss25UnimplementedTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTj -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTq -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvpMV -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTj -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTq -_$ss26DispatchGlobalTaskExecutorCABycfC -_$ss26DispatchGlobalTaskExecutorCABycfCTj -_$ss26DispatchGlobalTaskExecutorCABycfCTq -_$ss26DispatchGlobalTaskExecutorCABycfc -_$ss26DispatchGlobalTaskExecutorCMa -_$ss26DispatchGlobalTaskExecutorCMm -_$ss26DispatchGlobalTaskExecutorCMn -_$ss26DispatchGlobalTaskExecutorCMo -_$ss26DispatchGlobalTaskExecutorCMu -_$ss26DispatchGlobalTaskExecutorCN -_$ss26DispatchGlobalTaskExecutorCScFsMc -_$ss26DispatchGlobalTaskExecutorCScFsWP -_$ss26DispatchGlobalTaskExecutorCSchsMc -_$ss26DispatchGlobalTaskExecutorCSchsWP -_$ss26DispatchGlobalTaskExecutorCfD -_$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1098,19 +1024,8 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp -_$ss5ClockP09CanonicalA0AB_sAATn -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq _$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj @@ -1121,12 +1036,6 @@ _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq _$ss5ClockP7InstantAB_s0B8ProtocolTn _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF -_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF -_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF _$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF _$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF diff --git a/test/abi/Inputs/macOS/x86_64/concurrency/baseline b/test/abi/Inputs/macOS/x86_64/concurrency/baseline index faf82a577e56d..9f91995fd1839 100644 --- a/test/abi/Inputs/macOS/x86_64/concurrency/baseline +++ b/test/abi/Inputs/macOS/x86_64/concurrency/baseline @@ -1,7 +1,6 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl -_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -478,31 +477,12 @@ _$ss12MainExecutorTL _$ss13_runAsyncMainyyyyYaKcF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lFTu -_$ss14CFMainExecutorC3runyyKF -_$ss14CFMainExecutorC4stopyyF -_$ss14CFMainExecutorCABycfC -_$ss14CFMainExecutorCABycfc -_$ss14CFMainExecutorCMa -_$ss14CFMainExecutorCMm -_$ss14CFMainExecutorCMn -_$ss14CFMainExecutorCMo -_$ss14CFMainExecutorCN -_$ss14CFMainExecutorCfD -_$ss14CFMainExecutorCfd -_$ss14CFTaskExecutorCABycfC -_$ss14CFTaskExecutorCABycfc -_$ss14CFTaskExecutorCMa -_$ss14CFTaskExecutorCMm -_$ss14CFTaskExecutorCMn -_$ss14CFTaskExecutorCMo -_$ss14CFTaskExecutorCN -_$ss14CFTaskExecutorCfD -_$ss14CFTaskExecutorCfd _$ss15ContinuousClockV17minimumResolutions8DurationVvg _$ss15ContinuousClockV17minimumResolutions8DurationVvpMV _$ss15ContinuousClockV3nowAB7InstantVvg _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV +_$ss15ContinuousClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ @@ -524,6 +504,7 @@ _$ss15ContinuousClockV7InstantVSLsMc _$ss15ContinuousClockV7InstantVSQsMc _$ss15ContinuousClockV7InstantVSesMc _$ss15ContinuousClockV7InstantVs0C8ProtocolsMc +_$ss15ContinuousClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15ContinuousClockVABycfC _$ss15ContinuousClockVMa _$ss15ContinuousClockVMn @@ -551,6 +532,7 @@ _$ss15SuspendingClockV17minimumResolutions8DurationVvpMV _$ss15SuspendingClockV3nowAB7InstantVvg _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV +_$ss15SuspendingClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ @@ -577,6 +559,7 @@ _$ss15SuspendingClockV7InstantVSLsMc _$ss15SuspendingClockV7InstantVSQsMc _$ss15SuspendingClockV7InstantVSesMc _$ss15SuspendingClockV7InstantVs0C8ProtocolsMc +_$ss15SuspendingClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15SuspendingClockVABycfC _$ss15SuspendingClockVMa _$ss15SuspendingClockVMn @@ -701,38 +684,6 @@ _$ss20AsyncFlatMapSequenceVMa _$ss20AsyncFlatMapSequenceVMn _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc -_$ss20DispatchMainExecutorC02isbC0Sbvg -_$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13checkIsolatedyyF -_$ss20DispatchMainExecutorC3runyyKFTj -_$ss20DispatchMainExecutorC3runyyKFTq -_$ss20DispatchMainExecutorC4stopyyFTj -_$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF -_$ss20DispatchMainExecutorCABycfC -_$ss20DispatchMainExecutorCABycfCTj -_$ss20DispatchMainExecutorCABycfCTq -_$ss20DispatchMainExecutorCABycfc -_$ss20DispatchMainExecutorCMa -_$ss20DispatchMainExecutorCMm -_$ss20DispatchMainExecutorCMn -_$ss20DispatchMainExecutorCMo -_$ss20DispatchMainExecutorCMu -_$ss20DispatchMainExecutorCN -_$ss20DispatchMainExecutorCScFsMc -_$ss20DispatchMainExecutorCScFsWP -_$ss20DispatchMainExecutorCScfsMc -_$ss20DispatchMainExecutorCScfsWP -_$ss20DispatchMainExecutorCfD -_$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs010SchedulingC0sMc -_$ss20DispatchMainExecutorCs010SchedulingC0sWP -_$ss20DispatchMainExecutorCs07RunLoopC0sMc -_$ss20DispatchMainExecutorCs07RunLoopC0sWP -_$ss20DispatchMainExecutorCs0bC0sMc -_$ss20DispatchMainExecutorCs0bC0sWP _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lF _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lFTu _$ss21withUnsafeCurrentTask4bodyxxSctSgKXE_tKlF @@ -913,31 +864,6 @@ _$ss25UnimplementedTaskExecutorCSchsMc _$ss25UnimplementedTaskExecutorCSchsWP _$ss25UnimplementedTaskExecutorCfD _$ss25UnimplementedTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTj -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTq -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvpMV -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTj -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTq -_$ss26DispatchGlobalTaskExecutorCABycfC -_$ss26DispatchGlobalTaskExecutorCABycfCTj -_$ss26DispatchGlobalTaskExecutorCABycfCTq -_$ss26DispatchGlobalTaskExecutorCABycfc -_$ss26DispatchGlobalTaskExecutorCMa -_$ss26DispatchGlobalTaskExecutorCMm -_$ss26DispatchGlobalTaskExecutorCMn -_$ss26DispatchGlobalTaskExecutorCMo -_$ss26DispatchGlobalTaskExecutorCMu -_$ss26DispatchGlobalTaskExecutorCN -_$ss26DispatchGlobalTaskExecutorCScFsMc -_$ss26DispatchGlobalTaskExecutorCScFsWP -_$ss26DispatchGlobalTaskExecutorCSchsMc -_$ss26DispatchGlobalTaskExecutorCSchsWP -_$ss26DispatchGlobalTaskExecutorCfD -_$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1098,19 +1024,8 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp -_$ss5ClockP09CanonicalA0AB_sAATn -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq _$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj @@ -1121,12 +1036,6 @@ _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq _$ss5ClockP7InstantAB_s0B8ProtocolTn _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF -_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF -_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF _$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF _$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF diff --git a/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts b/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts index faf82a577e56d..9f91995fd1839 100644 --- a/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts +++ b/test/abi/Inputs/macOS/x86_64/concurrency/baseline-asserts @@ -1,7 +1,6 @@ $ld$previous$@rpath/libswift_Concurrency.dylib$$1$10.9$12.0$$ $ld$previous$@rpath/libswift_Concurrency.dylib$$6$13.1$15.0$$ _$s13AsyncIteratorSciTl -_$s14CanonicalClocks0B0PTl _$s7ElementScITl _$s7ElementSciTl _$s7Instants5ClockPTl @@ -478,31 +477,12 @@ _$ss12MainExecutorTL _$ss13_runAsyncMainyyyyYaKcF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lF _$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lFTu -_$ss14CFMainExecutorC3runyyKF -_$ss14CFMainExecutorC4stopyyF -_$ss14CFMainExecutorCABycfC -_$ss14CFMainExecutorCABycfc -_$ss14CFMainExecutorCMa -_$ss14CFMainExecutorCMm -_$ss14CFMainExecutorCMn -_$ss14CFMainExecutorCMo -_$ss14CFMainExecutorCN -_$ss14CFMainExecutorCfD -_$ss14CFMainExecutorCfd -_$ss14CFTaskExecutorCABycfC -_$ss14CFTaskExecutorCABycfc -_$ss14CFTaskExecutorCMa -_$ss14CFTaskExecutorCMm -_$ss14CFTaskExecutorCMn -_$ss14CFTaskExecutorCMo -_$ss14CFTaskExecutorCN -_$ss14CFTaskExecutorCfD -_$ss14CFTaskExecutorCfd _$ss15ContinuousClockV17minimumResolutions8DurationVvg _$ss15ContinuousClockV17minimumResolutions8DurationVvpMV _$ss15ContinuousClockV3nowAB7InstantVvg _$ss15ContinuousClockV3nowAB7InstantVvgZ _$ss15ContinuousClockV3nowAB7InstantVvpMV +_$ss15ContinuousClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15ContinuousClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15ContinuousClockV7InstantV1loiySbAD_ADtFZ @@ -524,6 +504,7 @@ _$ss15ContinuousClockV7InstantVSLsMc _$ss15ContinuousClockV7InstantVSQsMc _$ss15ContinuousClockV7InstantVSesMc _$ss15ContinuousClockV7InstantVs0C8ProtocolsMc +_$ss15ContinuousClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15ContinuousClockVABycfC _$ss15ContinuousClockVMa _$ss15ContinuousClockVMn @@ -551,6 +532,7 @@ _$ss15SuspendingClockV17minimumResolutions8DurationVvpMV _$ss15SuspendingClockV3nowAB7InstantVvg _$ss15SuspendingClockV3nowAB7InstantVvgZ _$ss15SuspendingClockV3nowAB7InstantVvpMV +_$ss15SuspendingClockV3run_2at9toleranceys11ExecutorJobVn_AB7InstantVs8DurationVSgtF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKF _$ss15SuspendingClockV5sleep5until9toleranceyAB7InstantV_s8DurationVSgtYaKFTu _$ss15SuspendingClockV7InstantV1loiySbAD_ADtFZ @@ -577,6 +559,7 @@ _$ss15SuspendingClockV7InstantVSLsMc _$ss15SuspendingClockV7InstantVSQsMc _$ss15SuspendingClockV7InstantVSesMc _$ss15SuspendingClockV7InstantVs0C8ProtocolsMc +_$ss15SuspendingClockV7enqueue_2on2at9toleranceys11ExecutorJobVn_xAB7InstantVs8DurationVSgtScFRzlF _$ss15SuspendingClockVABycfC _$ss15SuspendingClockVMa _$ss15SuspendingClockVMn @@ -701,38 +684,6 @@ _$ss20AsyncFlatMapSequenceVMa _$ss20AsyncFlatMapSequenceVMn _$ss20AsyncFlatMapSequenceV_9transformAByxq_Gx_q_7ElementQzYactcfC _$ss20AsyncFlatMapSequenceVyxq_GScisMc -_$ss20DispatchMainExecutorC02isbC0Sbvg -_$ss20DispatchMainExecutorC02isbC0SbvpMV -_$ss20DispatchMainExecutorC13checkIsolatedyyF -_$ss20DispatchMainExecutorC3runyyKFTj -_$ss20DispatchMainExecutorC3runyyKFTq -_$ss20DispatchMainExecutorC4stopyyFTj -_$ss20DispatchMainExecutorC4stopyyFTq -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss20DispatchMainExecutorC7enqueue_2at9tolerance5clockys0C3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss20DispatchMainExecutorC7enqueueyys0C3JobVnF -_$ss20DispatchMainExecutorCABycfC -_$ss20DispatchMainExecutorCABycfCTj -_$ss20DispatchMainExecutorCABycfCTq -_$ss20DispatchMainExecutorCABycfc -_$ss20DispatchMainExecutorCMa -_$ss20DispatchMainExecutorCMm -_$ss20DispatchMainExecutorCMn -_$ss20DispatchMainExecutorCMo -_$ss20DispatchMainExecutorCMu -_$ss20DispatchMainExecutorCN -_$ss20DispatchMainExecutorCScFsMc -_$ss20DispatchMainExecutorCScFsWP -_$ss20DispatchMainExecutorCScfsMc -_$ss20DispatchMainExecutorCScfsWP -_$ss20DispatchMainExecutorCfD -_$ss20DispatchMainExecutorCfd -_$ss20DispatchMainExecutorCs010SchedulingC0sMc -_$ss20DispatchMainExecutorCs010SchedulingC0sWP -_$ss20DispatchMainExecutorCs07RunLoopC0sMc -_$ss20DispatchMainExecutorCs07RunLoopC0sWP -_$ss20DispatchMainExecutorCs0bC0sMc -_$ss20DispatchMainExecutorCs0bC0sWP _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lF _$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lFTu _$ss21withUnsafeCurrentTask4bodyxxSctSgKXE_tKlF @@ -913,31 +864,6 @@ _$ss25UnimplementedTaskExecutorCSchsMc _$ss25UnimplementedTaskExecutorCSchsWP _$ss25UnimplementedTaskExecutorCfD _$ss25UnimplementedTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTj -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvgTq -_$ss26DispatchGlobalTaskExecutorC06isMainD0SbvpMV -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTj -_$ss26DispatchGlobalTaskExecutorC7enqueue_2at9tolerance5clockys0D3JobVn_7InstantQz8DurationQzSgxts5ClockRzlFTq -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTj -_$ss26DispatchGlobalTaskExecutorC7enqueueyys0D3JobVnFTq -_$ss26DispatchGlobalTaskExecutorCABycfC -_$ss26DispatchGlobalTaskExecutorCABycfCTj -_$ss26DispatchGlobalTaskExecutorCABycfCTq -_$ss26DispatchGlobalTaskExecutorCABycfc -_$ss26DispatchGlobalTaskExecutorCMa -_$ss26DispatchGlobalTaskExecutorCMm -_$ss26DispatchGlobalTaskExecutorCMn -_$ss26DispatchGlobalTaskExecutorCMo -_$ss26DispatchGlobalTaskExecutorCMu -_$ss26DispatchGlobalTaskExecutorCN -_$ss26DispatchGlobalTaskExecutorCScFsMc -_$ss26DispatchGlobalTaskExecutorCScFsWP -_$ss26DispatchGlobalTaskExecutorCSchsMc -_$ss26DispatchGlobalTaskExecutorCSchsWP -_$ss26DispatchGlobalTaskExecutorCfD -_$ss26DispatchGlobalTaskExecutorCfd -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sMc -_$ss26DispatchGlobalTaskExecutorCs010SchedulingD0sWP _$ss27AsyncThrowingFilterSequenceV04makeA8IteratorAB0F0Vyx_GyF _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvg _$ss27AsyncThrowingFilterSequenceV10isIncludedySb7ElementQzYaKcvpMV @@ -1098,19 +1024,8 @@ _$ss3JobVN _$ss3JobVyABScJcfC _$ss3JobVyABs08ExecutorA0VncfC _$ss5ClockMp -_$ss5ClockP09CanonicalA0AB_sAATn -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTj -_$ss5ClockP09canonicalA009CanonicalA0QzSgvgTq _$ss5ClockP17minimumResolution8DurationQzvgTj _$ss5ClockP17minimumResolution8DurationQzvgTq -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTj -_$ss5ClockP18convertToCanonical7instant0dA0_7InstantQZAFQz_tFTq -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTj -_$ss5ClockP18convertToCanonical8duration0dA0_8DurationQZAFQz_tFTq -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tFTq -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTj -_$ss5ClockP23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tFTq _$ss5ClockP3now7InstantQzvgTj _$ss5ClockP3now7InstantQzvgTq _$ss5ClockP3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtFTj @@ -1121,12 +1036,6 @@ _$ss5ClockP5sleep5until9tolerancey7InstantQz_8DurationQzSgtYaKFTq _$ss5ClockP7InstantAB_s0B8ProtocolTn _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTj _$ss5ClockP7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lFTq -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvg -_$ss5ClockPs09CanonicalA0QzRszrlE09canonicalA0xSgvpMV -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB07instant7InstantQzAH_tF -_$ss5ClockPs09CanonicalA0QzRszrlE09convertToB08duration8DurationQzAH_tF -_$ss5ClockPsE23maybeConvertToCanonical7instant0eA0_7InstantQZSgAFQzSg_tF -_$ss5ClockPsE23maybeConvertToCanonical8duration0eA0_8DurationQZSgAFQzSg_tF _$ss5ClockPsE3run_2at9toleranceys11ExecutorJobVn_7InstantQz8DurationQzSgtF _$ss5ClockPsE7enqueue_2on2at9toleranceys11ExecutorJobVn_qd__7InstantQz8DurationQzSgtScFRd__lF _$ss5ClockPsE7measurey8DurationQzyyKXEKF From e1c9a05959a8025221dafc8e747ae45518d591d0 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 14 Jul 2025 12:23:55 +0100 Subject: [PATCH 10/11] [Concurrency] Update some comments. A few comment updates after Konrad's suggestions on the PR. --- stdlib/public/Concurrency/Clock.swift | 6 +++--- stdlib/public/Concurrency/PartialAsyncTask.swift | 7 +++---- test/Concurrency/Runtime/sleep_executor.swift | 6 +++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index d75bb4d098732..c36847fd07ab6 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -58,7 +58,7 @@ public protocol Clock: Sendable { /// given instant. /// /// The default implementation uses the `run` method to trigger a job that - /// does `executor.enqueue(job)`. If a particular `Clock` knows that the + /// does `executor.enqueue(job)`. If a particular ``Clock`` knows that the /// executor it has been asked to use is the same one that it will run jobs /// on, it can short-circuit this behaviour and directly use `run` with /// the original job. @@ -88,8 +88,8 @@ extension Clock { run(trampoline, at: instant, tolerance: tolerance) } - // Clocks that do not implement run will fatalError() if you try to use - // them with an executor that does not understand them. + // Clocks that do not implement this method will fatalError() if you try to + // use them with an executor that does not understand them. @available(StdlibDeploymentTarget 6.2, *) public func run(_ job: consuming ExecutorJob, at instant: Instant, tolerance: Duration?) { diff --git a/stdlib/public/Concurrency/PartialAsyncTask.swift b/stdlib/public/Concurrency/PartialAsyncTask.swift index be23f9b3e6784..69ba8edbc7dae 100644 --- a/stdlib/public/Concurrency/PartialAsyncTask.swift +++ b/stdlib/public/Concurrency/PartialAsyncTask.swift @@ -456,11 +456,10 @@ extension ExecutorJob { // executor. extension ExecutorJob { - /// Create a trampoline to enqueue the specified job on the specified - /// executor. + /// Create a trampoline to enqueue this job on the specified executor. /// - /// This is useful in conjunction with the `Clock.run()` API, which - /// runs a job on an unspecified executor. + /// This is useful in conjunction with the ``Clock.run(_:at:tolerance:)`` API, + /// which runs a job on an unspecified executor. /// /// - Parameters: /// diff --git a/test/Concurrency/Runtime/sleep_executor.swift b/test/Concurrency/Runtime/sleep_executor.swift index daeb25a44ed02..237f9541b4a43 100644 --- a/test/Concurrency/Runtime/sleep_executor.swift +++ b/test/Concurrency/Runtime/sleep_executor.swift @@ -37,7 +37,11 @@ final class TestExecutor: TaskExecutor, SchedulingExecutor, @unchecked Sendable after delay: C.Duration, tolerance: C.Duration? = nil, clock: C) { - // Convert to `Swift.Duration` + // Convert to `Swift.Duration`; this happens to work for the built-in + // clocks, since they use `Swift.Duration` as their `Duration` type. + // If we get a crash here, it's because someone made a clock that didn't + // do that, and we're somehow using it instead of `ContinuousClock` or + // `SuspendingCLock`. let duration = delay as! Swift.Duration // Now turn that into nanoseconds From c0adefcca4853ad30cf4d0382a561442431d79b8 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 15 Jul 2025 10:58:17 +0100 Subject: [PATCH 11/11] [Concurrency] Fix minimal stdlib build. We were using `ExecutorJob` in a couple of places without a `#if`. --- stdlib/public/Concurrency/Clock.swift | 4 +++- stdlib/public/Concurrency/ContinuousClock.swift | 2 +- stdlib/public/Concurrency/SuspendingClock.swift | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index c36847fd07ab6..1a10208630be2 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -38,7 +38,7 @@ public protocol Clock: Sendable { var now: Instant { get } var minimumResolution: Instant.Duration { get } -#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY +#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY func sleep(until deadline: Instant, tolerance: Instant.Duration?) async throws /// Run the given job on an unspecified executor at some point @@ -77,6 +77,7 @@ public protocol Clock: Sendable { #endif } +#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY extension Clock { // The default implementation works by creating a trampoline and calling // the run() method. @@ -96,6 +97,7 @@ extension Clock { fatalError("\(Self.self) does not implement run(_:at:tolerance:).") } } +#endif @available(StdlibDeploymentTarget 5.7, *) extension Clock { diff --git a/stdlib/public/Concurrency/ContinuousClock.swift b/stdlib/public/Concurrency/ContinuousClock.swift index d258528ec3561..80ba7bdc51d1b 100644 --- a/stdlib/public/Concurrency/ContinuousClock.swift +++ b/stdlib/public/Concurrency/ContinuousClock.swift @@ -212,7 +212,7 @@ extension ContinuousClock.Instant: InstantProtocol { } } -#if !$Embedded +#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @available(StdlibDeploymentTarget 6.2, *) extension ContinuousClock { diff --git a/stdlib/public/Concurrency/SuspendingClock.swift b/stdlib/public/Concurrency/SuspendingClock.swift index df3ef9bc6029e..6696ae7767d41 100644 --- a/stdlib/public/Concurrency/SuspendingClock.swift +++ b/stdlib/public/Concurrency/SuspendingClock.swift @@ -190,7 +190,7 @@ extension SuspendingClock.Instant: InstantProtocol { } } -#if !$Embedded +#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY @available(StdlibDeploymentTarget 6.2, *) extension SuspendingClock {