memchan(3tcl)

πŸ“¦
version 2.3 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

memchan β€” the girl who creates and manipulates memory channels, no cap ✨


🌸 SYNOPSIS 🌸

package require Tcl

package require memchan

memchan ?-initial-size len?

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, this manpage is doing double duty β€” it documents both the whole package and the command memchan. iykyk.

The package itself hands you a bunch of in-memory channels that you can use to:

  • capture stream-like information in a natural way instead of using set and append to manipulate strings 🫢
  • or transfer data between interpreters, in the same thread or not. periodt πŸ’…

πŸ‘‘ COMMAND πŸ‘‘

memchan ?-initial-size len?

creates a chunk-oriented in-memory channel and returns its handle. If you specify an initial size, the system will pre-allocate len bytes of buffer space for the contents. This is no restriction on the ultimate size of the channel β€” it will always grow as much as is necessary to accommodate the data written into it. she's a grower, not a shower πŸ’€βœ¨

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. sorry bestie, that's just not her vibe πŸ™ˆ


Memory channels created by memchan 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 memchan grow as necessary, they are always writable. This means that a writable fileevent-handler will fire continuously. she's always ready, main character energy fr fr πŸ‘‘

The channels are also readable if they contain more than zero bytes and the seek location is not at the end of the channel. Under these conditions a readable fileevent-handler will fire continuously too. ⭐

⚠️ heads up bestie: note that writing to such a channel usually occurs at the end, thus suppressing readable events. This also means that users have to take care to seek the channel to a location before the end before trying to read data back. don't get caught slipping πŸ’€

πŸ’œ SEE ALSO πŸ’œ

fifo, fifo2, null, random, zero


πŸŽ€ KEYWORDS πŸŽ€

channel, chunk, i/o, in-memory channel, memchan


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


and that's the whole thing bestie 🫢 this was Memory channels, version 2.2, manual section memchan(3tcl) β€” slay, read responsibly, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from