1 USING: accessors calendar concurrency.count-downs continuations
2 destructors fry io io.encodings io.encodings.binary
3 io.encodings.utf8 io.pipes io.streams.duplex io.streams.string
4 io.timeouts kernel math namespaces threads tools.test ;
14 { { } } [ { } run-pipeline ] unit-test
15 { { f } } [ { [ f ] } run-pipeline ] unit-test
18 { [ input-stream [ utf8 <decoder> ] change readln ] } run-pipeline
24 [ output-stream [ utf8 <encoder> ] change "Hello" print flush f ]
25 [ input-stream [ utf8 <decoder> ] change readln ]
32 1 seconds over set-timeout
37 ! Test writing to a half-open pipe
42 [ out>> "hi" over stream-write dispose ]
48 ! Test non-blocking operation
51 2 <count-down> "count-down" set
59 "count-down" get count-down
63 ! Give the threads enough time to start blocking on
67 ! At this point, two threads are blocking on read
68 [ [ "Hi" over stream-write stream-flush ] bi@ ]
69 ! At this point, both threads should wake up
72 "count-down" get await
76 ! 0 read should not block
79 binary <pipe> &dispose
81 [ 0 read ] with-input-stream