1 USING: io io.pipes io.streams.string io.encodings.utf8
2 io.encodings.binary io.streams.duplex io.encodings io.timeouts
3 namespaces continuations tools.test kernel calendar destructors
4 accessors debugger math sequences threads
5 concurrency.count-downs fry ;
16 { { } } [ { } run-pipeline ] unit-test
17 { { f } } [ { [ f ] } run-pipeline ] unit-test
20 { [ input-stream [ utf8 <decoder> ] change readln ] } run-pipeline
26 [ output-stream [ utf8 <encoder> ] change "Hello" print flush f ]
27 [ input-stream [ utf8 <decoder> ] change readln ]
34 1 seconds over set-timeout
39 ! Test writing to a half-open pipe
44 [ out>> "hi" over stream-write dispose ]
50 ! Test non-blocking operation
53 2 <count-down> "count-down" set
61 "count-down" get count-down
65 ! Give the threads enough time to start blocking on
69 ! At this point, two threads are blocking on read
70 [ [ "Hi" over stream-write stream-flush ] bi@ ]
71 ! At this point, both threads should wake up
74 "count-down" get await
78 ! 0 read should not block
81 binary <pipe> &dispose
83 [ 0 read ] with-input-stream