1 IN: concurrency.flags.tests
\r
2 USING: tools.test concurrency.flags concurrency.combinators
\r
3 kernel threads locals accessors calendar ;
\r
5 :: flag-test-1 ( -- val )
\r
6 [let | f [ <flag> ] |
\r
7 [ f raise-flag ] "Flag test" spawn drop
\r
12 [ f ] [ flag-test-1 ] unit-test
\r
14 :: flag-test-2 ( -- )
\r
15 [let | f [ <flag> ] |
\r
16 [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop
\r
21 [ f ] [ flag-test-2 ] unit-test
\r
23 :: flag-test-3 ( -- val )
\r
24 [let | f [ <flag> ] |
\r
29 [ t ] [ flag-test-3 ] unit-test
\r
31 :: flag-test-4 ( -- val )
\r
32 [let | f [ <flag> ] |
\r
33 [ f raise-flag ] "Flag test" spawn drop
\r
38 [ t ] [ flag-test-4 ] unit-test
\r
40 :: flag-test-5 ( -- val )
\r
41 [let | f [ <flag> ] |
\r
42 [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop
\r
47 [ t ] [ flag-test-5 ] unit-test
\r
51 [ [ 1 seconds sleep raise-flag ] curry "Flag test" spawn drop ]
\r
52 [ [ wait-for-flag drop ] curry parallel-each ] bi
\r