]> gitweb.factorcode.org Git - factor.git/blob - basis/concurrency/exchangers/exchangers-tests.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / basis / concurrency / exchangers / exchangers-tests.factor
1 USING: tools.test concurrency.exchangers\r
2 concurrency.count-downs concurrency.promises locals kernel\r
3 threads ;\r
4 FROM: sequences => 3append ;\r
5 IN: concurrency.exchangers.tests\r
6 \r
7 :: exchanger-test ( -- string )\r
8     [let |\r
9         ex [ <exchanger> ]\r
10         c [ 2 <count-down> ]\r
11         v1! [ f ]\r
12         v2! [ f ]\r
13         pr [ <promise> ] |\r
14 \r
15         [\r
16             c await\r
17             v1 ", " v2 3append pr fulfill\r
18         ] "Awaiter" spawn drop\r
19 \r
20         [\r
21             "Goodbye world" ex exchange v1! c count-down\r
22         ] "Exchanger 1" spawn drop\r
23 \r
24         [\r
25             "Hello world" ex exchange v2! c count-down\r
26         ] "Exchanger 2" spawn drop\r
27 \r
28         pr ?promise\r
29     ] ;\r
30 \r
31 [ "Hello world, Goodbye world" ] [ exchanger-test ] unit-test\r