reject_edge_two_spawns.mx raw
1 // One pair, one child: passing the same Edge to two spawn calls would give two
2 // domains the same handles (docs/memory-model.md section 4, D19 rule 4).
3 //
4 // expected: already passed to spawn
5 package main
6
7 type Req struct {
8 Body []byte `cap:"1024"`
9 }
10
11 func worker(ep Edge[Req, int32]) (closed chan struct{}) {
12 for {
13 select {
14 case <-closed:
15 return closed
16 case r := <-ep.Recv:
17 _ = r
18 }
19 }
20 }
21
22 func main() {
23 select {
24 case <-shutdown:
25 return
26 default:
27 }
28 parent, child := edge[int32, Req]{2}
29 a := spawn(worker, child)
30 b := spawn(worker, child)
31 close(parent.Send)
32 <-a
33 <-b
34 }
35