1 // A spawned domain (A) spawns a child (B) and then parks in a receive that only
2 // B can wake. The shape is the parked-parent one, one level deeper: A is a
3 // child of the root AND the parent of B, so the channel's direction has to be
4 // decided per channel, not by the domain's own role. Natively this hung until
5 // the direction was keyed on the channel's child-domain token; on wasm the page
6 // starts B, so A may be parked while B starts.
7 package main
8 9 func b(c chan int32) (closed chan struct{}) {
10 select {
11 case <-closed:
12 return closed
13 default:
14 }
15 c <- 7
16 return closed
17 }
18 19 func a() (closed chan struct{}) {
20 select {
21 case <-closed:
22 return closed
23 default:
24 }
25 c := chan int32{:1}
26 bDone := spawn(b, c)
27 v := <-c
28 println("a got", v)
29 <-bDone
30 println("a saw b done")
31 return closed
32 }
33 34 func main() {
35 select {
36 case <-shutdown:
37 return
38 default:
39 }
40 done := spawn(a)
41 println("root spawned a")
42 <-done
43 println("done")
44 }
45