Skip to content

Commit 2d31b6d

Browse files
committed
rename Job type
1 parent 8ff0e9a commit 2d31b6d

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

stdlib/public/Concurrency/Executor.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ import Swift
1717
public protocol Executor: AnyObject, Sendable {
1818

1919
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
20-
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
21-
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
22-
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
23-
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
20+
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
21+
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
22+
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
23+
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
2424
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2525
func enqueue(_ job: UnownedJob)
2626

2727
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2828
@available(SwiftStdlib 5.9, *)
29-
func enqueue(_ job: __owned Job)
29+
func enqueue(_ job: __owned ExecutorJob)
3030
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
3131
}
3232

@@ -39,10 +39,10 @@ public protocol SerialExecutor: Executor {
3939
// work-scheduling operation.
4040
@_nonoverride
4141
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
42-
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
43-
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
44-
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
45-
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned Job)' instead")
42+
@available(macOS, introduced: 10.15, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
43+
@available(iOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
44+
@available(watchOS, introduced: 6.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
45+
@available(tvOS, introduced: 13.0, deprecated: 9999, message: "Implement 'enqueue(_: __owned ExecutorJob)' instead")
4646
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
4747
func enqueue(_ job: UnownedJob)
4848

@@ -53,7 +53,7 @@ public protocol SerialExecutor: Executor {
5353
// work-scheduling operation.
5454
@_nonoverride
5555
@available(SwiftStdlib 5.9, *)
56-
func enqueue(_ job: __owned Job)
56+
func enqueue(_ job: __owned ExecutorJob)
5757
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
5858

5959
/// Convert this executor value to the optimized form of borrowed
@@ -87,10 +87,10 @@ public protocol SerialExecutor: Executor {
8787
@available(SwiftStdlib 5.9, *)
8888
extension Executor {
8989
public func enqueue(_ job: UnownedJob) {
90-
self.enqueue(Job(job))
90+
self.enqueue(ExecutorJob(job))
9191
}
9292

93-
public func enqueue(_ job: __owned Job) {
93+
public func enqueue(_ job: __owned ExecutorJob) {
9494
self.enqueue(UnownedJob(job))
9595
}
9696
}
@@ -219,10 +219,10 @@ func _checkExpectedExecutor(_filenameStart: Builtin.RawPointer,
219219

220220
/// Primarily a debug utility.
221221
///
222-
/// If the passed in Job is a Task, returns the complete 64bit TaskId,
222+
/// If the passed in ExecutorJob is a Task, returns the complete 64bit TaskId,
223223
/// otherwise returns only the job's 32bit Id.
224224
///
225-
/// - Returns: the Id stored in this Job or Task, for purposes of debug printing
225+
/// - Returns: the Id stored in this ExecutorJob or Task, for purposes of debug printing
226226
@available(SwiftStdlib 5.9, *)
227227
@_silgen_name("swift_task_getJobTaskId")
228228
internal func _getJobTaskId(_ job: UnownedJob) -> UInt64
@@ -250,7 +250,7 @@ internal func _enqueueOnExecutor<E>(job unownedJob: UnownedJob, executor: E)
250250
where E: SerialExecutor {
251251
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
252252
if #available(SwiftStdlib 5.9, *) {
253-
executor.enqueue(Job(context: unownedJob._context))
253+
executor.enqueue(ExecutorJob(context: unownedJob._context))
254254
} else {
255255
executor.enqueue(unownedJob)
256256
}

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Swift
1414
@_implementationOnly import _SwiftConcurrencyShims
1515

16-
// TODO(swift): rename the file to Job.swift eventually, we don't use PartialTask terminology anymore
16+
// TODO(swift): rename the file to ExecutorJob.swift eventually, we don't use PartialTask terminology anymore
1717

1818
@available(SwiftStdlib 5.1, *)
1919
@_silgen_name("swift_job_run")
@@ -65,7 +65,7 @@ public struct UnownedJob: Sendable {
6565
/// Deprecated API to run a job on a specific executor.
6666
@_alwaysEmitIntoClient
6767
@inlinable
68-
@available(*, deprecated, renamed: "Job.runSynchronously(on:)")
68+
@available(*, deprecated, renamed: "ExecutorJob.runSynchronously(on:)")
6969
public func _runSynchronously(on executor: UnownedSerialExecutor) {
7070
_swiftJobRun(self, executor)
7171
}
@@ -105,14 +105,19 @@ extension UnownedJob: CustomStringConvertible {
105105
}
106106

107107
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
108+
109+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
110+
@available(*, deprecated, renamed: "ExecutorJob")
111+
public typealias Job = ExecutorJob
112+
108113
/// A unit of scheduleable work.
109114
///
110115
/// Unless you're implementing a scheduler,
111116
/// you don't generally interact with jobs directly.
112117
@available(SwiftStdlib 5.9, *)
113118
@frozen
114119
@_moveOnly
115-
public struct Job: Sendable {
120+
public struct ExecutorJob: Sendable {
116121
internal var context: Builtin.Job
117122

118123
@usableFromInline
@@ -145,7 +150,7 @@ public struct Job: Sendable {
145150
}
146151

147152
@available(SwiftStdlib 5.9, *)
148-
extension Job {
153+
extension ExecutorJob {
149154

150155
/// Run this job on the passed in executor.
151156
///
@@ -158,7 +163,7 @@ extension Job {
158163
///
159164
/// This operation consumes the job, preventing it accidental use after it has ben run.
160165
///
161-
/// Converting a `Job` to an ``UnownedJob`` and invoking ``UnownedJob/runSynchronously(_:)` on it multiple times is undefined behavior,
166+
/// Converting a `ExecutorJob` to an ``UnownedJob`` and invoking ``UnownedJob/runSynchronously(_:)` on it multiple times is undefined behavior,
162167
/// as a job can only ever be run once, and must not be accessed after it has been run.
163168
///
164169
/// - Parameter executor: the executor this job will be semantically running on.
@@ -182,7 +187,7 @@ extension Job {
182187
/// However, the semantics of how priority is treated are left up to each
183188
/// platform and `Executor` implementation.
184189
///
185-
/// A Job's priority is roughly equivalent to a `TaskPriority`,
190+
/// A ExecutorJob's priority is roughly equivalent to a `TaskPriority`,
186191
/// however, since not all jobs are tasks, represented as separate type.
187192
///
188193
/// Conversions between the two priorities are available as initializers on the respective types.

test/Concurrency/custom_executor_enqueue_impls.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class OldExecutor: SerialExecutor {
2525
/// That's why we do log the deprecation warning, people should use the move-only version.
2626
final class BothExecutor: SerialExecutor {
2727
func enqueue(_ job: UnownedJob) {} // expected-warning{{'Executor.enqueue(UnownedJob)' is deprecated as a protocol requirement; conform type 'BothExecutor' to 'Executor' by implementing 'func enqueue(Job)' instead}}
28-
func enqueue(_ job: __owned Job) {}
28+
func enqueue(_ job: __owned ExecutorJob) {}
2929

3030
func asUnownedSerialExecutor() -> UnownedSerialExecutor {
3131
UnownedSerialExecutor(ordinary: self)
@@ -45,7 +45,7 @@ final class NoneExecutor: SerialExecutor { // expected-error{{type 'NoneExecutor
4545

4646
/// Just implementing the new signature causes no warnings, good.
4747
final class NewExecutor: SerialExecutor {
48-
func enqueue(_ job: __owned Job) {} // no warnings
48+
func enqueue(_ job: __owned ExecutorJob) {} // no warnings
4949

5050
func asUnownedSerialExecutor() -> UnownedSerialExecutor {
5151
UnownedSerialExecutor(ordinary: self)

0 commit comments

Comments
 (0)