|tcl::chan::halfpipe(3tcl)||Reflected/virtual channel support||tcl::chan::halfpipe(3tcl)|
tcl::chan::halfpipe - In-memory channel, half of a fifo2
package require Tcl 8.5
package require TclOO
package require tcl::chan::events ?1?
package require tcl::chan::halfpipe ?1.0.1?
::tcl::chan::halfpipe ?-option value...?
objectCmd put bytes
The tcl::chan::halfpipe package provides a command creating one half of a tcl::chan::fifo2 pair. Writing into such a channel invokes a set of callbacks which then handle the data. This is similar to a channel handler, except having a much simpler API.
The internal TclOO class implementing the channel handler is a sub-class of the tcl::chan::events framework.
- ::tcl::chan::halfpipe ?-option value...?
- This command creates a halfpipe channel and configures it with the
callbacks to run when the channel is closed, data was written to it, or
ran empty. See the section Options for the list of options and
associated semantics. The result of the command is a list containing two
elements, the handle of the new channel, and the object command of the
channel handler, in this order. The latter is supplied to the caller to
provide her with access to the put method for adding data to the
Two halfpipes with a bit of glue logic in the callbacks make for one tcl::chan::fifo2.
- objectCmd put bytes
- This method of the channel handler object puts the data bytes into the channel so that it can be read from it.
- -close-command cmdprefix
- This callback is invoked when the channel is closed. A single argument is supplied, the handle of the channel being closed. The result of the callback is ignored.
- -write-command cmdprefix
- This callback is invoked when data is written to the channel. Two arguments are supplied, the handle of the channel written to, and the data written. The result of the callback is ignored.
- -empty-command cmdprefix
- This callback is invoked when the channel has run out of data to read. A single argument is supplied, the handle of the channel.
BUGS, IDEAS, FEEDBACK¶
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category virtchannel of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
callbacks, fifo, in-memory channel, reflected channel, tip 219, virtual channel
Copyright (c) 2009, 2019 Andreas Kupries <email@example.com>