1
2memchan(n) memchan(n)
3
4
5
7 memchan - Create and manipulate memory channels
8
10 package require Tcl
11
12 package require memchan
13
14 memchan ?-initial-size len?
15
16
18 This manpage documents both the overall package and the command mem‐
19 chan. The package itself provides a number of in-memory channels which
20 can utilized to
21
22 · capture stream-like information in a natural way instead of
23 using set and append to manipulate strings
24
25 · or to transfer data between interpreters, in the same thread or
26 not.
27
29 memchan ?-initial-size len?
30 creates a chunk-oriented in-memory channel and returns its han‐
31 dle. If an initial size is specified the system will pre-allo‐
32 cate len bytes of buffer space for the contents. This is no
33 restriction on the ultimate size of the channel, it will always
34 grow as much as is necessary to accomodate the data written into
35 it.
36
37 The channels created here can be transfered between interpreters
38 in the same thread and between threads, but only as a whole. It
39 is not possible to use them to create a bi- or unidirectional
40 connection between two interpreters.
41
42 Memory channels created by memchan provide two read-only options which
43 can be queried via the standard fconfigure command. These are
44
45 -length
46 The value of this option is the number of bytes currently stored
47 in the queried memory channel.
48
49 -allocated
50 The value of this option is the number of bytes currently allo‐
51 cated by the queried memory channel. This number is at least as
52 big as the value of -length.
53
54 As the channels generated by memchan grow as necessary they are always
55 writable. This means that a writable fileevent-handler will fire con‐
56 tinuously.
57
58 The channels are also readable if they contain more than zero bytes and
59 the seek location is not and the end of the channel. Under these condi‐
60 tions a readable fileevent-handler will fire continuously.
61
62 Note that writing to such a channel usually occurs at the end, thus
63 supressing readable events. This also means that users have to take
64 care to seek the channel to a location before the end before trying to
65 read data back.
66
68 fifo, fifo2, null, zero, random
69
71 memchan, chunk, in-memory channel, channel, i/o
72
74 Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>
75
76
77
78Memory channels 2.2 memchan(n)