Drop reference counts ASAP in case it saves us some memory
sooner rather than later. This ought to give us more predictable
resource use and ensure OnDestroy callbacks fire sooner.
There's no need to use `local' to clobber the arrayref anymore,
either.
AFAIK, this doesn't fix any known bug, but more predictability
will make it easier to debug things going forward.
sub now () { clock_gettime(CLOCK_MONOTONIC) }
sub next_tick () {
- local $cur_runq = $nextq or return;
+ $cur_runq = $nextq or return;
$nextq = undef;
- for my $obj (@$cur_runq) {
+ while (my $obj = shift @$cur_runq) {
# avoid "ref" on blessed refs to workaround a Perl 5.16.3 leak:
# https://rt.perl.org/Public/Bug/Display.html?id=114340
- if (blessed($obj)) {
- $obj->event_step;
- } else {
- $obj->();
- }
+ blessed($obj) ? $obj->event_step : $obj->();
}
}