@@ -25,20 +25,14 @@ extension WithSpecifiedExecutor {
25
25
}
26
26
27
27
final class NaiveQueueExecutor : SpecifiedExecutor , CustomStringConvertible {
28
+ let name : String
28
29
let queue : DispatchQueue
29
30
30
- init ( _ queue: DispatchQueue ) {
31
+ init ( name: String , _ queue: DispatchQueue ) {
32
+ self . name = name
31
33
self . queue = queue
32
34
}
33
35
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
-
42
36
public func enqueue( _ job: __owned Job) {
43
37
print ( " \( self ) : enqueue " )
44
38
let unowned = UnownedJob ( job)
@@ -49,7 +43,7 @@ final class NaiveQueueExecutor: SpecifiedExecutor, CustomStringConvertible {
49
43
}
50
44
51
45
var description : Swift . String {
52
- " NaiveQueueExecutor( \( queue ) ) "
46
+ " NaiveQueueExecutor( \( name ) ) "
53
47
}
54
48
}
55
49
@@ -74,8 +68,9 @@ actor MyActor: WithSpecifiedExecutor {
74
68
@main struct Main {
75
69
static func main( ) async {
76
70
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)
79
74
let actor = MyActor ( executor: one)
80
75
await actor . test ( expectedExecutor: one, expectedQueue: queue)
81
76
await actor . test ( expectedExecutor: one, expectedQueue: queue)
@@ -85,9 +80,9 @@ actor MyActor: WithSpecifiedExecutor {
85
80
}
86
81
87
82
// 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
93
88
// CHECK-NEXT: end
0 commit comments