factor/library/io/duplex-stream.factor

41 lines
1.0 KiB
Factor
Raw Normal View History

2005-06-19 18:31:02 -04:00
! Combine an input and output stream into one, and flush the
! stream more often.
USING: io kernel ;
TUPLE: duplex-stream in out flush? ;
M: duplex-stream stream-flush
duplex-stream-out stream-flush ;
M: duplex-stream stream-finish
2005-06-19 18:31:02 -04:00
dup duplex-stream-flush?
2005-09-24 15:21:17 -04:00
[ duplex-stream-out stream-flush ] [ drop ] if ;
2005-06-19 18:31:02 -04:00
M: duplex-stream stream-readln
duplex-stream-in stream-readln ;
M: duplex-stream stream-read1
duplex-stream-in stream-read1 ;
2005-06-19 18:31:02 -04:00
M: duplex-stream stream-read
duplex-stream-in stream-read ;
M: duplex-stream stream-write1
duplex-stream-out stream-write1 ;
2005-06-19 18:31:02 -04:00
M: duplex-stream stream-format
duplex-stream-out stream-format ;
2005-06-19 18:31:02 -04:00
M: duplex-stream stream-close
2005-06-23 22:35:41 -04:00
#! The output stream is closed first, in case both streams
#! are attached to the same file descriptor, the output
#! buffer needs to be flushed before we close the fd.
2005-06-23 15:55:17 -04:00
dup
2005-06-23 22:35:41 -04:00
duplex-stream-out stream-close
duplex-stream-in stream-close ;
2005-06-19 18:31:02 -04:00
M: duplex-stream set-timeout
2dup
duplex-stream-in set-timeout
duplex-stream-out set-timeout ;