1memchan(n)                                                          memchan(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       memchan - Create and manipulate memory channels
9

SYNOPSIS

11       package require Tcl
12
13       package require memchan
14
15       memchan ?-initial-size len?
16
17______________________________________________________________________________
18

DESCRIPTION

20       This  manpage  documents  both the overall package and the command mem‐
21       chan. The package itself provides a number of in-memory channels  which
22       can utilized to
23
24       ·      capture  stream-like  information  in  a  natural way instead of
25              using set and append to manipulate strings
26
27       ·      or to transfer data between interpreters, in the same thread  or
28              not.
29

COMMAND

31       memchan ?-initial-size len?
32              creates  a chunk-oriented in-memory channel and returns its han‐
33              dle. If an initial size is specified the system  will  pre-allo‐
34              cate  len  bytes  of  buffer  space for the contents. This is no
35              restriction on the ultimate size of the channel, it will  always
36              grow  as  much  as  is necessary to accommodate the data written
37              into it.
38
39              The channels created here  can  be  transferred  between  inter‐
40              preters  in  the  same thread and between threads, but only as a
41              whole. It is not possible to use them to create a bi- or  unidi‐
42              rectional connection between two interpreters.
43
44       Memory  channels created by memchan provide two read-only options which
45       can be queried via the standard fconfigure command. These are
46
47       -length
48              The value of this option is the number of bytes currently stored
49              in the queried memory channel.
50
51       -allocated
52              The  value of this option is the number of bytes currently allo‐
53              cated by the queried memory channel. This number is at least  as
54              big as the value of -length.
55
56       As  the channels generated by memchan grow as necessary they are always
57       writable. This means that a writable fileevent-handler will  fire  con‐
58       tinuously.
59
60       The channels are also readable if they contain more than zero bytes and
61       the seek location is not and the end of the channel. Under these condi‐
62       tions a readable fileevent-handler will fire continuously.
63
64       Note  that  writing  to  such a channel usually occurs at the end, thus
65       suppressing readable events. This also means that users  have  to  take
66       care  to seek the channel to a location before the end before trying to
67       read data back.
68

SEE ALSO

70       fifo, fifo2, null, random, zero
71

KEYWORDS

73       channel, chunk, i/o, in-memory channel, memchan
74
76       Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>
77
78
79
80
81Memory channels                       2.2                           memchan(n)
Impressum