fifo(3tcl)

๐Ÿ“ฆ
version 2.3 ยท 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– fifo โ€” the manual page, bestie edition ๐Ÿ’–

okay so real talk, this is fifo from the Tcl manual, section 3tcl. it's a whole page about making u-turn fifo channels and honestly? it's giving iconic. let's get into it ๐Ÿซถ


โœจ NAME โœจ

fifo โ€” create and manipulate u-turn fifo channels ๐ŸŒˆ


โœจ SYNOPSIS โœจ

package require Tcl

package require memchan

fifo

โœจ DESCRIPTION โœจ

so fifo creates a stream-oriented in-memory channel and hands you back its handle. that's it, that's the whole vibe ๐Ÿ’…

and there is no restriction on the ultimate size of the channel, bestie โ€” it will always grow as much as is necessary to accommodate the data written into it. it does not care. it will simply expand. queen behavior ๐Ÿ‘‘

now here's the tea: in contrast to the channels generated by memchan, a channel created here effectively represents an U-turn ๐Ÿ”„. all data written into it can be read out, but only in the same order. this also means that a fifo channel is not seekable. no rewinding, no scrubbing, no taking it back. it's a one-way street that loops around, iykyk ๐Ÿ˜ญ

the channels created here can be transferred between interpreters in the same thread and between threads, but only as a whole. it is not possible to use them to create a bi- or unidirectional connection between two interpreters. so don't try it, she's not that kind of channel ๐Ÿ™ˆ


memory channels created by fifo provide two read-only options which can be queried via the standard fconfigure command. these are:

  • -length โ€” the value of this option is the number of bytes currently stored in the queried memory channel ๐Ÿ“
  • -allocated โ€” the value of this option is the number of bytes currently allocated by the queried memory channel. this number is at least as big as the value of -length ๐Ÿงฎ

as the channels generated by fifo grow as necessary they are always writable. this means that a writable fileevent-handler will fire continuously. like, constantly. forever. she never stops talking ๐Ÿ”ฅ

the channels are also readable if they contain more than zero bytes. under this conditions a readable fileevent-handler will fire continuously. (yes bestie, "this conditions" โ€” that's what the original says, we don't edit the queen's grammar ๐Ÿ’€)

โš ๏ธ heads up: those continuously-firing handlers are literally in the spec. don't come for me, come for the fileevent system.

โœจ NOTES โœจ

one possible application of memory channels created by memchan or fifo is as a temporary storage device to collect data coming in over a pipe or a socket ๐Ÿ“

if part of the processing of the incoming data is to read and process header bytes or similar, fifo are easier to use as they do not require seeking back and forth to switch between the assimilation of headers at the beginning and writing new data at the end. no bouncing around, just vibes โœจ


โœจ SEE ALSO โœจ

  • fifo2
  • memchan
  • null

go read those too, bestie, they're all in the group chat ๐Ÿ“š


โœจ KEYWORDS โœจ

  • channel
  • fifo
  • i/o
  • in-memory channel
  • memchan
  • stream

Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole page, no cap. this was Memory channels, version 2.1, filed under fifo(3tcl) โ€” huge thank you to Andreas Kupries for writing it back in 1996-2003, an absolute legend, we stan ๐Ÿ’œ ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from