tcl::chan::halfpipe(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– tcl::chan::halfpipe(n) πŸ’–

okay bestie, so this is a page from the Reflected/virtual channel support manual, and it's about tcl::chan::halfpipe β€” literally the most "half a friendship necklace" energy in the whole Tcllib. pull up a chair 🫢


✨ NAME ✨

tcl::chan::halfpipe β€” an in-memory channel that is exactly half of a fifo2 🌸


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require TclOO

package require tcl::chan::events ?1.1?

package require tcl::chan::halfpipe ?1.0.2?

::tcl::chan::halfpipe ?-option value...?

objectCmd put bytes

✨ DESCRIPTION ✨

So the tcl::chan::halfpipe package gives you a command that makes one half of a tcl::chan::fifo2 pair. the way that writing into one of these channels just... invokes a set of callbacks, and those callbacks handle the data? obsessed. it's like a channel handler but with a way simpler API, no cap πŸ’…

the internal TclOO class doing the channel-handler work is a sub-class of the tcl::chan::events framework. iykyk πŸ¦‹


✨ API ✨

  • ::tcl::chan::halfpipe ?-option value...? β€” this one creates a halfpipe channel and configures it with the callbacks that run when the channel is closed, when data gets written to it, or when it ran empty. (peep the Options section for the full list of options and what they actually mean.) the result of the command is a list with two elements, in this order: the handle of the new channel, and the object command of the channel handler. that second one is handed back to you so you have access to the put method for adding data into the channel. πŸŽ€

and listen β€” two halfpipes with a lil bit of glue logic in the callbacks make for one tcl::chan::fifo2. it's giving soulmates fr fr.

  • objectCmd put bytes β€” this method on the channel handler object puts the data bytes into the channel, so it can be read from it. ⭐

✨ OPTIONS ✨

  • -close-command cmdprefix β€” this callback fires when the channel is closed. one single argument gets supplied: the handle of the channel being closed. the result of the callback is ignored, bestie. πŸ™ˆ
  • -write-command cmdprefix β€” this callback fires when data is written to the channel. two arguments get supplied: the handle of the channel written to, and the data written. and yep, the result of the callback is ignored. ✨
  • -empty-command cmdprefix β€” this callback fires when the channel has run out of data to read. a single argument gets supplied: the handle of the channel. πŸ’€

✨ BUGS, IDEAS, FEEDBACK ✨

ngl, this document β€” and the package it describes β€” will undoubtedly contain bugs and other problems. please report those in the category virtchannel of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. πŸ›

also please report any ideas for enhancements you may have for either the package and/or the documentation. we love ideas here. 🫢

when proposing code changes, please provide unified diffs, i.e. the output of diff -u. no vibes-based patches, bestie.

note further that attachments are strongly preferred over inlined patches. you can make attachments 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. πŸ‘‘


✨ KEYWORDS ✨

callbacks, fifo, in-memory channel, reflected channel, tip 219, virtual channel 🌈


✨ CATEGORY ✨

Channels πŸ’œ


Copyright (c) 2009, 2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole thing, periodt πŸ’… this page is tcllib version 1.0.2, and the manpage is tcl::chan::halfpipe(n) β€” mwah, slay, go build your fifo2 πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from