Skip to content

Commit 443f95e

Browse files
committed
dispatch queue seems to be printed inconsistently; fix test
1 parent f2de5d8 commit 443f95e

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

test/Concurrency/Runtime/custom_executors_protocol.swift

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,14 @@ extension WithSpecifiedExecutor {
2525
}
2626

2727
final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
28+
let name: String
2829
let queue: DispatchQueue
2930

30-
init(_ queue: DispatchQueue) {
31+
init(name: String, _ queue: DispatchQueue) {
32+
self.name = name
3133
self.queue = queue
3234
}
3335

34-
public func enqueue(_ job: UnownedJob) {
35-
print("\(self): enqueue")
36-
queue.sync {
37-
job.runSynchronously(on: self.asUnownedSerialExecutor())
38-
}
39-
print("\(self): after run")
40-
}
41-
4236
public func enqueue(_ job: __owned Job) {
4337
print("\(self): enqueue")
4438
let unowned = UnownedJob(job)
@@ -49,7 +43,7 @@ final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
4943
}
5044

5145
var description: Swift.String {
52-
"NaiveQueueExecutor(\(queue))"
46+
"NaiveQueueExecutor(\(name))"
5347
}
5448
}
5549

@@ -74,8 +68,9 @@ actor MyActor: WithSpecifiedExecutor {
7468
@main struct Main {
7569
static func main() async {
7670
print("begin")
77-
let queue = DispatchQueue(label: "CustomQueue")
78-
let one = NaiveQueueExecutor(queue)
71+
let name = "CustomQueue"
72+
let queue = DispatchQueue(label: name)
73+
let one = NaiveQueueExecutor(name: name, queue)
7974
let actor = MyActor(executor: one)
8075
await actor.test(expectedExecutor: one, expectedQueue: queue)
8176
await actor.test(expectedExecutor: one, expectedQueue: queue)
@@ -85,9 +80,9 @@ actor MyActor: WithSpecifiedExecutor {
8580
}
8681

8782
// CHECK: begin
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
83+
// CHECK-NEXT: NaiveQueueExecutor(CustomQueue): enqueue
84+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(CustomQueue)
85+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(CustomQueue)
86+
// CHECK-NEXT: MyActor: on executor NaiveQueueExecutor(CustomQueue)
87+
// CHECK-NEXT: NaiveQueueExecutor(CustomQueue): after run
9388
// CHECK-NEXT: end

0 commit comments

Comments
 (0)