1 USING: threads concurrency.messaging kernel
2 tools.time math sequences ;
7 : tunnel ( process -- process )
8 receive 2dup swap send done eq? [ tunnel ] unless ;
10 : create-ring ( processes -- target )
12 dup [ tunnel ] curry "Tunnel" spawn nip
15 : send-messages ( messages target -- )
16 dupd [ send ] curry each [ receive drop ] times ;
18 : destroy-ring ( target -- )
19 done swap send [ done eq? ] receive-if drop ;
21 : ring-bench ( messages processes -- )
22 create-ring [ send-messages ] keep destroy-ring ;
24 : main-ring-bench ( -- )
25 1000 1000 ring-bench ;