Skip to content

Commit f75a6e9

Browse files
committed
capture the known problem with multiple actorReady calls in async inits
We haven't yet integrated more deeply into DI to prevent the multiple calls.
1 parent e545557 commit f75a6e9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/Distributed/Runtime/distributed_actor_init_local.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ distributed actor LocalWorker {
2525
init(transport: ActorTransport) {}
2626
}
2727

28+
@available(SwiftStdlib 5.5, *)
29+
distributed actor Bug_CallsReadyTwice {
30+
var x: Int
31+
init(transport: ActorTransport, wantBug: Bool) async {
32+
if wantBug {
33+
self.x = 1
34+
}
35+
self.x = 2
36+
}
37+
}
38+
2839
// ==== Fake Transport ---------------------------------------------------------
2940

3041
@available(SwiftStdlib 5.5, *)
@@ -81,6 +92,17 @@ func test() async {
8192
_ = await PickATransport2(other: 1, theTransport: transport)
8293
// CHECK: assign type:PickATransport2, id:ActorAddress(address: "[[ID:.*]]")
8394
// CHECK: ready actor:main.PickATransport2, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
95+
96+
_ = await Bug_CallsReadyTwice(transport: transport, wantBug: true)
97+
// CHECK: assign type:Bug_CallsReadyTwice, id:ActorAddress(address: "[[ID:.*]]")
98+
// CHECK: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
99+
// CHECK-NEXT: ready actor:main.Bug_CallsReadyTwice, id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
100+
101+
// TODO: it's not obvious why the resigns happen later for the async ones.
102+
// might need to find a way to force the deallocation at a specific point,
103+
// or just use check-dag or something.
104+
105+
// CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
84106
// CHECK: resign id:AnyActorIdentity(ActorAddress(address: "[[ID]]"))
85107
}
86108

0 commit comments

Comments
 (0)