… | |
… | |
208 | sub connect { |
208 | sub connect { |
209 | # we are trivially connected |
209 | # we are trivially connected |
210 | } |
210 | } |
211 | |
211 | |
212 | # delay every so often to avoid recursion, also used to delay after spawn |
212 | # delay every so often to avoid recursion, also used to delay after spawn |
213 | our $DELAY; |
213 | our $DELAY = -50; |
214 | our @DELAY; |
214 | our @DELAY; |
215 | our $DELAY_W; |
215 | our $DELAY_W; |
216 | |
216 | |
217 | sub _send_delayed { |
217 | sub _send_delayed { |
218 | local $AnyEvent::MP::Kernel::SRCNODE = $AnyEvent::MP::Kernel::NODE{""}; |
218 | local $AnyEvent::MP::Kernel::SRCNODE = $AnyEvent::MP::Kernel::NODE{""}; |
… | |
… | |
259 | or $AnyEvent::MP::Kernel::WARN->(8, "unmonitored local port $port died with reason: @reason"); |
259 | or $AnyEvent::MP::Kernel::WARN->(8, "unmonitored local port $port died with reason: @reason"); |
260 | |
260 | |
261 | $_->(@reason) for values %$mon; |
261 | $_->(@reason) for values %$mon; |
262 | }; |
262 | }; |
263 | |
263 | |
264 | $DELAY_W ? push @DELAY, $delay_cb : &$delay_cb; |
264 | # we _always_ delay kil's, to avoid calling mon callbacks |
|
|
265 | # from anything but the event loop context. |
|
|
266 | $DELAY = 1; |
|
|
267 | push @DELAY, $delay_cb; |
|
|
268 | $DELAY_W ||= AE::timer 0, 0, \&_send_delayed; |
265 | } |
269 | } |
266 | |
270 | |
267 | sub monitor { |
271 | sub monitor { |
268 | my ($self, $portid, $cb) = @_; |
272 | my ($self, $portid, $cb) = @_; |
269 | |
273 | |