Skip to content

Commit 86d046b

Browse files
committed
cleanup
1 parent a20e7b3 commit 86d046b

10 files changed

+35
-200
lines changed

stdlib/public/BackDeployConcurrency/Actor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ JobPriority swift::swift_task_getCurrentThreadPriority() {
285285
SWIFT_CC(swift)
286286
static bool swift_task_isCurrentExecutorImpl(ExecutorRef executor) {
287287
if (auto currentTracking = ExecutorTrackingInfo::current()) {
288-
currentTracking->getActiveExecutor().getIdentity(),
289-
currentTracking->getActiveExecutor().isMainExecutor() ? "y" : "n",
290-
currentTracking->getActiveExecutor().isDefaultActor() ? "y" : "n");
291288
return currentTracking->getActiveExecutor() == executor;
292289
}
293290

stdlib/public/Concurrency/Actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static bool swift_task_isCurrentExecutorImpl(ExecutorRef executor) {
301301
return currentTracking->getActiveExecutor() == executor;
302302
}
303303

304-
// TODO(ktoso): checking the "is main thread" is not correct, main executor can be not main thread
304+
// TODO(ktoso): checking the "is main thread" is not correct, main executor can be not main thread, relates to rdar://106188692
305305
return executor.isMainExecutor() && isExecutingOnMainThread();
306306
}
307307

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
107107
UncheckedContinuation.swift
108108
GlobalActor.swift
109109
MainActor.swift
110-
Job.swift
110+
PartialAsyncTask.swift
111111
SourceCompatibilityShims.swift
112112
Task.cpp
113113
Task.swift

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,30 @@ public struct UnownedJob: Sendable {
5656
public func _runSynchronously(on executor: UnownedSerialExecutor) {
5757
_swiftJobRun(self, executor)
5858
}
59+
60+
@_alwaysEmitIntoClient
61+
@inlinable
62+
public func runSynchronously(on executor: UnownedSerialExecutor) {
63+
_swiftJobRun(self, executor)
64+
}
65+
5966
}
6067

68+
@available(SwiftStdlib 5.9, *)
69+
extension UnownedJob: CustomStringConvertible {
70+
@available(SwiftStdlib 5.9, *)
71+
public var description: String {
72+
let id = _getJobTaskId(self)
73+
/// Tasks are always assigned an unique ID, however some jobs may not have it set,
74+
/// and it appearing as 0 for _different_ jobs may lead to misunderstanding it as
75+
/// being "the same 0 id job", we specifically print 0 (id not set) as nil.
76+
if (id > 0) {
77+
return "\(Self.self)(id: \(id))"
78+
} else {
79+
return "\(Self.self)(id: nil)"
80+
}
81+
}
82+
}
6183

6284
/// A unit of scheduleable work.
6385
///
@@ -79,8 +101,7 @@ public struct Job: Sendable {
79101
}
80102

81103
public var priority: JobPriority {
82-
// let raw = _swift_concurrency_jobPriority(UnownedJob(context: self.context)) // TODO: do we also surface this or the base priority?
83-
let raw = _taskCurrentPriority(context as! Builtin.NativeObject)
104+
let raw = _swift_concurrency_jobPriority(UnownedJob(context: self.context))
84105
return JobPriority(rawValue: raw)
85106
}
86107

test/Concurrency/Runtime/custom_executors_assume_main_asyncmain.swift

Lines changed: 0 additions & 44 deletions
This file was deleted.

test/Concurrency/Runtime/custom_executors_assume_main_asyncmain_crash.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/Concurrency/Runtime/custom_executors_default.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift( -Xfrontend enable-experimental-move-only -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library) | %FileCheck %s
1+
// RUN: %target-run-simple-swift( -Xfrontend -enable-experimental-move-only -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library) | %FileCheck %s
22

33
// REQUIRES: concurrency
44
// REQUIRES: executable_test

test/Concurrency/Runtime/custom_executors_distributed.swift

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/Concurrency/Runtime/custom_executors_priority.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift( -Xfrontend -enable-experimental-move-only -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library) | %FileCheck %s
1+
// RUN: %target-run-simple-swift( -Xfrontend -enable-experimental-move-only -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library) | %FileCheck %s --dump-input=always
22

33
// REQUIRES: concurrency
44
// REQUIRES: executable_test
@@ -41,9 +41,6 @@ actor Custom {
4141
await Task() {
4242
await actor.report()
4343
}.value
44-
await Task(priority: .low) {
45-
await actor.report()
46-
}.value
4744
print("end")
4845
}
4946
}

test/Concurrency/Runtime/custom_executors_protocol.swift

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,6 @@ extension WithSpecifiedExecutor {
2424
}
2525
}
2626

27-
final class InlineExecutor: SpecifiedExecutor, CustomStringConvertible {
28-
let name: String
29-
30-
init(_ name: String) {
31-
self.name = name
32-
}
33-
34-
public func enqueue(_ job: UnownedJob) {
35-
print("\(self): enqueue")
36-
job.runSynchronously(on: self.asUnownedSerialExecutor())
37-
print("\(self): after run")
38-
}
39-
40-
public func enqueue(_ job: __owned Job) {
41-
print("\(self): enqueue")
42-
job.runSynchronously(on: self)
43-
print("\(self): after run")
44-
}
45-
46-
var description: Swift.String {
47-
"InlineExecutor(\(name))"
48-
}
49-
}
50-
5127
final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
5228
let queue: DispatchQueue
5329

@@ -58,7 +34,7 @@ final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
5834
public func enqueue(_ job: UnownedJob) {
5935
print("\(self): enqueue")
6036
queue.sync {
61-
job.runSynchronously(on: self)
37+
job.runSynchronously(on: self.asUnownedSerialExecutor())
6238
}
6339
print("\(self): after run")
6440
}
@@ -67,7 +43,7 @@ final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
6743
print("\(self): enqueue")
6844
let unowned = UnownedJob(job)
6945
queue.sync {
70-
unowned.runSynchronously(on: self)
46+
unowned.runSynchronously(on: self.asUnownedSerialExecutor())
7147
}
7248
print("\(self): after run")
7349
}
@@ -89,7 +65,7 @@ actor MyActor: WithSpecifiedExecutor {
8965
}
9066

9167
func test(expectedExecutor: some SerialExecutor, expectedQueue: DispatchQueue) {
92-
precondition(_taskIsOnExecutor(expectedExecutor), "Expected to be on: \(expectedExecutor)")
68+
// FIXME(waiting on preconditions to merge): preconditionTaskOnExecutor(expectedExecutor, "Expected to be on: \(expectedExecutor)")
9369
dispatchPrecondition(condition: .onQueue(expectedQueue))
9470
print("\(Self.self): on executor \(expectedExecutor)")
9571
}
@@ -109,9 +85,9 @@ actor MyActor: WithSpecifiedExecutor {
10985
}
11086

11187
// CHECK: begin
112-
// CHECK-NEXT: InlineExecutor(one): enqueue
113-
// CHECK-NEXT: MyActor: on executor InlineExecutor(one)
114-
// CHECK-NEXT: MyActor: on executor InlineExecutor(one)
115-
// CHECK-NEXT: MyActor: on executor InlineExecutor(one)
116-
// CHECK-NEXT: InlineExecutor(one): after run
88+
// CHECK-NEXT: NaiveQueueExecutor(<OS_dispatch_queue_serial: CustomQueue>): enqueue
89+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(<OS_dispatch_queue_serial: CustomQueue>)
90+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(<OS_dispatch_queue_serial: CustomQueue>)
91+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(<OS_dispatch_queue_serial: CustomQueue>)
92+
// CHECK-NEXT: NaiveQueueExecutor(<OS_dispatch_queue_serial: CustomQueue>): after run
11793
// CHECK-NEXT: end

0 commit comments

Comments
 (0)