Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / Eventloop.pod
CommitLineData
86530b38
AT
1
2=head1 NAME
3
4Tk::Event - ToolKit for Events
5
6=for category Implementation
7
8=head1 SYNOPSIS
9
10 use Tk::Event;
11
12 Tk::Event->fileevent(\*FH, 'readable' => callback);
13
14 Tk::Event->lineavail(\*FH, callback);
15
16 use Tk::Event::Signal qw(INT);
17
18 $SIG{'INT'} = callback;
19
20 use Tk::Event::process;
21
22 Tk::Event->proc($pid, callback);
23
24 QueueEvent(callback [, position])
25
26
27=head1 DESCRIPTION
28
29
30That is better than nothing but still hard to use. Most scripts want higher
31level result (a line, a "block" of data etc.)
32
33So it has occured to me that we could use new-ish TIEHANDLE thus:
34
35my $obj = tie SOMEHANDLE,Tk::Event::IO;
36
37while (<SOMEHANDLE>)
38 {
39 }
40
41Then the READLINE routine registers a callback and looks something like:
42
43sub READLINE
44 {
45 my $obj = shift;
46 Event->io(*$obj,'readable',sub { sysread(*$obj,${*$obj},1,length(${*$obj}) });
47 my $pos;
48 while (($pos = index(${*$obj},$/) < 0)
49 {
50 DoOneEvent();
51 }
52 Event->io(*$obj,'readable',''); # unregister
53 $pos += length($/);
54 my $result = substr(${*$obj},0,$pos);
55 substr(${*$obj},0,$pos) = '';
56 return $result;
57 }
58
59This is using the scalar part of the glob representing the _inner_ IO
60as a buffer in which to accumulate chars.
61
62
63
64