… | |
… | |
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 | |
|
|
176 | our $DELAY_TIMER; |
|
|
177 | our @DELAY_QUEUE; |
|
|
178 | |
|
|
179 | sub _delay_run { |
|
|
180 | (shift @DELAY_QUEUE or return)->() while 1; |
|
|
181 | } |
|
|
182 | |
|
|
183 | sub delay($) { |
|
|
184 | push @DELAY_QUEUE, shift; |
|
|
185 | $DELAY_TIMER ||= AE::timer 0, 0, \&_delay_run; |
|
|
186 | } |
|
|
187 | |
176 | sub _inject { |
188 | sub _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 | |
237 | Executes C<snd> with the given C<@msg> (which must include the destination |
246 | Executes C<snd> with the given C<@msg> (which must include the destination |