[comment {-*- tcl -*- doctools}]
[manpage_begin fifo2 n 2.2]
[moddesc   {Memory channels}]
[titledesc {Create and manipulate pipe fifo channels}]
[copyright {1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>}]
[require Tcl]
[require memchan]
[description]
[para]
The command described here is only available in a not-yet released
version of the package. Use the CVS to get the sources.

[list_begin definitions]

[call [cmd fifo2]]

creates two stream-oriented in-memory channels and returns their
handles as a two-element list. There is no restriction on the ultimate
size of the channels, they will always grow as much as is necessary to
accommodate the data written into them.

[nl]
In contrast to the channels generated by [cmd fifo] a pair of channels
created here is connected internally in such a way that data written
into one channel can be read from the other. All data written into
them is read in the same order. This also means that the two channels
of the pair are not seekable.

[nl]
The channels created here can be transferred between interpreters in
the same thread and between threads. As both channels in the pair can
be transferred independently they can be used to create a bidirectional
connection between two interpreters.

[list_end]
[para]
Memory channels created by [cmd fifo2] provide two read-only options
which can be queried via the standard [cmd fconfigure] command. These
are

[list_begin definitions]
	[lst_item -rlength]

	The value of this option is the number of bytes currently
	available for reading from the channel.

	[lst_item -wlength]

	The value of this option is the number of bytes currently
	written into the channel.	
[list_end]
[para]
Note that the two lengths are switched for the channels of a pair. In
other words, the number of bytes written for one of the channels is
the number of bytes readable from the other end.

[para]
As the channels generated by [cmd fifo2] grow as necessary they are
always writable. This means that a writable [cmd fileevent]-handler
will fire continuously.

[para]
The channels are also readable if they contain more than zero
bytes. Under this conditions a readable [cmd fileevent]-handler will
fire continuously.

[see_also memchan fifo null]
[keywords fifo stream memchan {in-memory channel} channel i/o]
[manpage_end]
