Skip to content

Commit 795afbc

Browse files
committed
remove moveonly Job APIs from the task-to-thread model
1 parent bd6d5fa commit 795afbc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

stdlib/public/Concurrency/Executor.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ import Swift
1616
@available(SwiftStdlib 5.1, *)
1717
public protocol Executor: AnyObject, Sendable {
1818

19+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
1920
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
2021
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
2122
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
2223
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
24+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2325
func enqueue(_ job: UnownedJob)
2426

27+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2528
@available(SwiftStdlib 5.9, *)
2629
func enqueue(_ job: __owned Job)
30+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2731
}
2832

2933
/// A service that executes jobs.
@@ -34,26 +38,31 @@ public protocol SerialExecutor: Executor {
3438
// avoid drilling down to the base conformance just for the basic
3539
// work-scheduling operation.
3640
@_nonoverride
41+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
3742
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
3843
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
3944
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
4045
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
46+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
4147
func enqueue(_ job: UnownedJob)
4248

49+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
4350
// This requirement is repeated here as a non-override so that we
4451
// get a redundant witness-table entry for it. This allows us to
4552
// avoid drilling down to the base conformance just for the basic
4653
// work-scheduling operation.
4754
@_nonoverride
4855
@available(SwiftStdlib 5.9, *)
4956
func enqueue(_ job: __owned Job)
57+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
5058

5159
/// Convert this executor value to the optimized form of borrowed
5260
/// executor references.
5361
@available(SwiftStdlib 5.9, *)
5462
func asUnownedSerialExecutor() -> UnownedSerialExecutor
5563
}
5664

65+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
5766
@available(SwiftStdlib 5.9, *)
5867
extension Executor {
5968
public func enqueue(_ job: UnownedJob) {
@@ -64,6 +73,7 @@ extension Executor {
6473
self.enqueue(UnownedJob(job))
6574
}
6675
}
76+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
6777

6878
@available(SwiftStdlib 5.9, *)
6979
extension SerialExecutor {
@@ -159,11 +169,15 @@ internal func _getJobTaskId(_ job: UnownedJob) -> UInt64
159169
@_silgen_name("_swift_task_enqueueOnExecutor")
160170
internal func _enqueueOnExecutor<E>(job unownedJob: UnownedJob, executor: E)
161171
where E: SerialExecutor {
172+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
162173
if #available(SwiftStdlib 5.9, *) {
163174
executor.enqueue(Job(context: unownedJob._context))
164175
} else {
165176
executor.enqueue(unownedJob)
166177
}
178+
#else // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
179+
executor.enqueue(unownedJob)
180+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
167181
}
168182

169183
#if !SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public struct UnownedJob: Sendable {
4242
self.context = context
4343
}
4444

45+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
4546
/// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once.
4647
@available(SwiftStdlib 5.9, *)
4748
public init(_ job: __owned Job) {
4849
self.context = job.context
4950
}
51+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
5052

5153
/// The priority of this job.
5254
@available(SwiftStdlib 5.9, *)
@@ -102,7 +104,8 @@ extension UnownedJob: CustomStringConvertible {
102104
}
103105
}
104106

105-
/// A unit of scheduleable work.
107+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
108+
//// A unit of scheduleable work.
106109
///
107110
/// Unless you're implementing a scheduler,
108111
/// you don't generally interact with jobs directly.
@@ -165,6 +168,7 @@ extension Job {
165168
_swiftJobRun(UnownedJob(self), executor)
166169
}
167170
}
171+
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
168172

169173
// ==== -----------------------------------------------------------------------
170174
// MARK: JobPriority

0 commit comments

Comments
 (0)