about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-31 20:42:50 +0000
committerEric Wong <e@80x24.org>2023-11-01 07:08:08 +0000
commit196f753fb25447b7e8d61a5c0e4c62b464a8e03d (patch)
treea49ca5a890dfc23e27886bdd3c57ac6f572475af /lib/PublicInbox/DS.pm
parent1cbebe89b46091ef7f9f64e6bbda98f82cff2dd7 (diff)
downloadpublic-inbox-196f753fb25447b7e8d61a5c0e4c62b464a8e03d.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 6041c6b5..708fe14d 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -136,16 +136,12 @@ sub _InitPoller () {
 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->();
         }
 }