ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Kernel.pm
(Generate patch)

Comparing AnyEvent-MP/MP/Kernel.pm (file contents):
Revision 1.41 by root, Fri Sep 4 22:30:29 2009 UTC vs.
Revision 1.42 by root, Sat Sep 5 21:16:59 2009 UTC

171 *TRACE = $ENV{PERL_ANYEVENT_MP_TRACE} 171 *TRACE = $ENV{PERL_ANYEVENT_MP_TRACE}
172 ? sub () { 1 } 172 ? sub () { 1 }
173 : sub () { 0 }; 173 : sub () { 0 };
174} 174}
175 175
176our $DELAY_TIMER;
177our @DELAY_QUEUE;
178
179sub _delay_run {
180 (shift @DELAY_QUEUE or return)->() while 1;
181}
182
183sub delay($) {
184 push @DELAY_QUEUE, shift;
185 $DELAY_TIMER ||= AE::timer 0, 0, \&_delay_run;
186}
187
176sub _inject { 188sub _inject {
177 warn "RCV $SRCNODE->{id} -> " . (JSON::XS->new->encode (\@_)) . "\n" if TRACE && @_;#d# 189 warn "RCV $SRCNODE->{id} -> " . (JSON::XS->new->encode (\@_)) . "\n" if TRACE && @_;#d#
178 &{ $PORT{+shift} or return }; 190 &{ $PORT{+shift} or return };
179} 191}
180 192
224 236
225 # on $NODE, we artificially delay... (for spawn) 237 # on $NODE, we artificially delay... (for spawn)
226 # this is very ugly - maybe we should simply delay ALL messages, 238 # this is very ugly - maybe we should simply delay ALL messages,
227 # to avoid deep recursion issues. but that's so... slow... 239 # to avoid deep recursion issues. but that's so... slow...
228 my @msg = ("", @_); 240 my @msg = ("", @_);
229 my $to; $to = AE::timer 0, 0, sub {
230 undef $to;
231 $NODE{""}->send (\@msg); 241 delay sub { $NODE{""}->send (\@msg) };
232 };
233} 242}
234 243
235=item snd_on $node, @msg 244=item snd_on $node, @msg
236 245
237Executes C<snd> with the given C<@msg> (which must include the destination 246Executes C<snd> with the given C<@msg> (which must include the destination

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines