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

Comparing Coro/Coro/Event.pm (file contents):
Revision 1.1 by root, Sun Jul 15 03:24:18 2001 UTC vs.
Revision 1.2 by root, Sun Jul 15 15:58:16 2001 UTC

73 my $coronew = sub { 73 my $coronew = sub {
74 # how does one do method-call-by-name? 74 # how does one do method-call-by-name?
75 # my $w = $class->SUPER::$flavour(@_); 75 # my $w = $class->SUPER::$flavour(@_);
76 76
77 my $q = new Coro::Channel 0; 77 my $q = new Coro::Channel 0;
78 my $w;
78 my $w = $new->(@_, cb => sub { $q->put($_[0]) }); 79 $w = $new->(@_, parked => 1, cb => sub { $w->stop; $q->put($_[0]) });
79 $w->private($q); # using private as attribute is pretty useless... 80 $w->private($q); # using private as attribute is pretty useless...
80 bless $w, $class; # reblessing due to broken Event 81 bless $w, $class; # reblessing due to broken Event
81 }; 82 };
82 *{ $flavour } = $coronew; 83 *{ $flavour } = $coronew;
83 *{"do_$flavour"} = sub { 84 *{"do_$flavour"} = sub {
91Return the next event of the event queue of the watcher. 92Return the next event of the event queue of the watcher.
92 93
93=cut 94=cut
94 95
95sub next { 96sub next {
97 $_[0]->start;
96 $_[0]->private->get; 98 $_[0]->private->get;
97} 99}
98 100
99=item Coro::Event->main 101=item Coro::Event->main
100 102
101=cut 103=cut
102 104
103sub main { 105sub main {
104 local $Coro::idle = new Coro sub { 106 local $Coro::idle = new Coro sub {
105 while () {
106 Event::loop(5); 107 Event::loop;
107 print "in idle loop\n";#d#
108 }
109 }; 108 };
110 Coro::schedule; 109 Coro::schedule;
111} 110}
112 111
1131; 1121;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines