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.42 by root, Fri Dec 1 02:24:46 2006 UTC vs.
Revision 1.43 by root, Fri Dec 1 19:41:06 2006 UTC

116 116
117 shift eq Coro::Event:: 117 shift eq Coro::Event::
118 or croak "event constructor \"Coro::Event->$flavour\" must be called as a static method"; 118 or croak "event constructor \"Coro::Event->$flavour\" must be called as a static method";
119 119
120 my $w = $new->($class, 120 my $w = $new->($class,
121 desc => $flavour, 121 desc => $flavour,
122 @_, 122 @_,
123 parked => 1, 123 parked => 1,
124 ); 124 );
125
125 _install_std_cb($w, $type); 126 _install_std_cb $w, $type;
126 bless $w, $class; # reblessing due to broken Event 127
128 # reblessing due to Event being broken
129 bless $w, $class
127 }; 130 };
128 *{ $flavour } = $coronew; 131 *{ $flavour } = $coronew;
129 *{"do_$flavour"} = sub { 132 *{"do_$flavour"} = sub {
130 unshift @_, Coro::Event::; 133 unshift @_, Coro::Event::;
131 my $e = (&$coronew)->next; 134 my $e = &$coronew->next;
132 $e->cancel; # $e === $e->w 135 $e->cancel; # $e === $e->w
133 $e; 136 $e
134 }; 137 };
135} 138}
136 139
137# double calls to avoid stack-cloning ;() 140# do schedule in perl to avoid forcign a stack allocation.
138# is about 10% slower, though. 141# this is about 10% slower, though.
139sub next($) { 142sub next($) {
140 &Coro::schedule while &_next; 143 &Coro::schedule while &_next;
141 144
142 $_[0] 145 $_[0]
143} 146}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines