ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Event/Event.pm
(Generate patch)

Comparing Coro/Event/Event.pm (file contents):
Revision 1.46 by root, Fri Dec 29 12:05:55 2006 UTC vs.
Revision 1.47 by root, Wed Jan 24 16:22:08 2007 UTC

18 } 18 }
19 } 19 }
20 20
21 loop; 21 loop;
22 22
23 # wait for input on stdin for one second
24
25 Coro::Event::do_io (fd => \*STDIN, timeout => 1) & Event::Watcher::R
26 or die "no input received";
27
23=head1 DESCRIPTION 28=head1 DESCRIPTION
24 29
25This module enables you to create programs using the powerful Event model 30This module enables you to create programs using the powerful Event model
26(and module), while retaining the linear style known from simple or 31(and module), while retaining the linear style known from simple or
27threaded programs. 32threaded programs.
102 107
103=cut 108=cut
104 109
105=item $w->next 110=item $w->next
106 111
107Return the next event of the event queue of the watcher. 112Wait for and return the next event of the event queue of the watcher. The
113returned event objects support two methods only: C<hits> and C<got>, both
114of which return integers: the number this watcher was hit for this event,
115and the mask of poll events received.
108 116
109=cut 117=cut
110 118
111=item do_flavour args... 119=item do_flavour args...
112 120
113Create a watcher of the given type and immediately call it's next 121Create a watcher of the given type and immediately call it's next method,
122returning the event.
123
114method. This is less efficient then calling the constructor once and the 124This is less efficient then calling the constructor once and the next
115next method often, but it does save typing sometimes. 125method often, but it does save typing sometimes.
116 126
117=cut 127=cut
118 128
119for my $flavour (qw(idle var timer io signal)) { 129for my $flavour (qw(idle var timer io signal)) {
120 push @EXPORT, "do_$flavour"; 130 push @EXPORT, "do_$flavour";
156 &Coro::schedule while &_next; 166 &Coro::schedule while &_next;
157 167
158 &_event 168 &_event
159} 169}
160 170
171sub Coro::Event::Event::hits { $_[0][3] }
161sub Coro::Event::w { $_[0] } 172sub Coro::Event::Event::got { $_[0][4] }
162sub Coro::Event::prio { $_[0]{Coro::Event}[3] }
163sub Coro::Event::hits { $_[0]{Coro::Event}[4] }
164sub Coro::Event::got { $_[0]{Coro::Event}[5] }
165 173
166=item sweep 174=item sweep
167 175
168Similar to Event::one_event and Event::sweep: The idle task is called once 176Similar to Event::one_event and Event::sweep: The idle task is called once
169(this has the effect of jumping back into the Event loop once to serve new 177(this has the effect of jumping back into the Event loop once to serve new

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines