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-17 23:38:00 +0000
committerEric Wong <e@80x24.org>2023-10-18 20:50:31 +0000
commit2f61bdb6e39bd8079c0e5bd7f2366d3a473c6f68 (patch)
tree73552d93c42bc6333e6a48bdd165020a6106a471 /lib/PublicInbox/DS.pm
parenta4cf3bd57d17577b6dd791d4f0f8e76758d0aafe (diff)
downloadpublic-inbox-2f61bdb6e39bd8079c0e5bd7f2366d3a473c6f68.tar.gz
It's not worth the code and memory to have a setter method we
never use outside of tests.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm24
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 9960937d..6041c6b5 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -47,7 +47,7 @@ our (%AWAIT_PIDS, # pid => [ $callback, @args ]
 
      @post_loop_do,              # subref + args to call at the end of each loop
 
-     $LoopTimeout,               # timeout of event loop in milliseconds
+     $loop_timeout,               # timeout of event loop in milliseconds
      @Timers,                    # timers
      %UniqTimer,
      $in_loop,
@@ -89,20 +89,10 @@ sub Reset {
                 scalar(@{$cur_runq // []})); # do not vivify cur_runq
 
         $reap_armed = undef;
-        $LoopTimeout = -1;  # no timeout by default
+        $loop_timeout = -1;  # no timeout by default
         $Poller = PublicInbox::Select->new;
 }
 
-=head2 C<< CLASS->SetLoopTimeout( $timeout ) >>
-
-Set the loop timeout for the event loop to some value in milliseconds.
-
-A timeout of 0 (zero) means poll forever. A timeout of -1 means poll and return
-immediately.
-
-=cut
-sub SetLoopTimeout { $LoopTimeout = $_[1] + 0 }
-
 sub _add_named_timer {
         my ($name, $secs, $coderef, @args) = @_;
         my $fire_time = now() + $secs;
@@ -163,7 +153,7 @@ sub next_tick () {
 sub RunTimers {
         next_tick();
 
-        return (($nextq || $ToClose) ? 0 : $LoopTimeout) unless @Timers;
+        return (($nextq || $ToClose) ? 0 : $loop_timeout) unless @Timers;
 
         my $now = now();
 
@@ -177,16 +167,16 @@ sub RunTimers {
         # timers may enqueue into nextq:
         return 0 if ($nextq || $ToClose);
 
-        return $LoopTimeout unless @Timers;
+        return $loop_timeout unless @Timers;
 
         # convert time to an even number of milliseconds, adding 1
         # extra, otherwise floating point fun can occur and we'll
         # call RunTimers like 20-30 times, each returning a timeout
         # of 0.0000212 seconds
-        my $timeout = int(($Timers[0][0] - $now) * 1000) + 1;
+        my $t = int(($Timers[0][0] - $now) * 1000) + 1;
 
         # -1 is an infinite timeout, so prefer a real timeout
-        ($LoopTimeout < 0 || $LoopTimeout >= $timeout) ? $timeout : $LoopTimeout
+        ($loop_timeout < 0 || $loop_timeout >= $t) ? $t : $loop_timeout
 }
 
 sub sig_setmask { sigprocmask(SIG_SETMASK, @_) or die "sigprocmask: $!" }
@@ -305,7 +295,7 @@ sub event_loop (;$$) {
                 sig_setmask($oldset) if $oldset;
                 sigprocmask(SIG_UNBLOCK, unblockset($sig)) or
                         die "SIG_UNBLOCK: $!";
-                PublicInbox::DS->SetLoopTimeout(1000);
+                $loop_timeout = 1000;
         }
         $_[0] = $sigfd = $sig = undef; # $_[0] == sig
         local $in_loop = 1;