Skip to content

Commit

Permalink
io.pipes: adding docs for <connected-pair>.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed May 30, 2024
1 parent 6e8cf4f commit 8039b46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions basis/io/pipes/pipes-docs.factor
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ HELP: <pipe>
{ $description "Opens a new pipe and wraps it in a stream. Data written from the stream can be read back from the same stream instance." }
{ $notes "Pipe streams must be disposed by calling " { $link dispose } " or " { $link with-disposal } " to avoid resource leaks." } ;

HELP: <connected-pair>
{ $values { "encoding" "an encoding specifier" } { "stream" "a bidirectional stream" } }
{ $description "Opens two pipes wrapped into a stream. These are connected so that their " { $link input-stream } " redirects to the other pipe." } ;

HELP: run-pipeline
{ $values { "seq" "a sequence of pipeline components" } { "results" "a sequence of pipeline results" } }
{ $description
Expand Down
15 changes: 7 additions & 8 deletions basis/io/pipes/pipes-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ io.timeouts kernel math namespaces threads tools.test ;
] unit-test

{ "bar" "foo" } [
[
[let
utf8 <connected-pair> :> ( x y )
x y [ &dispose drop ] bi@
"foo\n" x stream-write x stream-flush
"bar\n" y stream-write y stream-flush
x y [ stream-readln ] bi@
]
[
[let
utf8 <connected-pair> &dispose :> ( x y )
"foo\n" x stream-write x stream-flush
"bar\n" y stream-write y stream-flush
x y [ stream-readln ] bi@
]
] with-destructors
] unit-test

0 comments on commit 8039b46

Please sign in to comment.