1
2fifo(n) fifo(n)
3
4
5
7 fifo - Create and manipulate u-turn fifo channels
8
10 package require Tcl
11
12 package require memchan
13
14 fifo
15
16
18 fifo creates a stream-oriented in-memory channel and returns its han‐
19 dle. There is no restriction on the ultimate size of the chan‐
20 nel, it will always grow as much as is necessary to accomodate
21 the data written into it.
22
23 In contrast to the channels generated by memchan a channel cre‐
24 ated here effectively represents an U-turn. All data written
25 into it can be read out, but only in the same order. This also
26 means that a fifo channel is not seekable.
27
28 The channels created here can be transfered between interpreters
29 in the same thread and between threads, but only as a whole. It
30 is not possible to use them to create a bi- or unidirectional
31 connection between two interpreters.
32
33 Memory channels created by fifo provide two read-only options which can
34 be queried via the standard fconfigure command. These are
35
36 -length
37 The value of this option is the number of bytes currently stored
38 in the queried memory channel.
39
40 -allocated
41 The value of this option is the number of bytes currently allo‐
42 cated by the queried memory channel. This number is at least as
43 big as the value of -length.
44
45 As the channels generated by fifo grow as necessary they are always
46 writable. This means that a writable fileevent-handler will fire con‐
47 tinuously.
48
49 The channels are also readable if they contain more than zero bytes.
50 Under this conditions a readable fileevent-handler will fire continu‐
51 ously.
52
54 One possible application of memory channels created by memchan or fifo
55 is as temporay storage device to collect data coming in over a pipe or
56 a socket. If part of the processing of the incoming data is to read and
57 process header bytes or similar fifo are easier to use as they do not
58 require seeking back and forth to switch between the assimilation of
59 headers at the beginning and writing new data at the end.
60
62 memchan, fifo2, null
63
65 fifo, stream, memchan, in-memory channel, channel, i/o
66
68 Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>
69
70
71
72Memory channels 2.1 fifo(n)