diff options
author | Eric Wong <e@yhbt.net> | 2020-06-27 10:03:44 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-06-28 22:27:20 +0000 |
commit | 62bb26d307a106d6c9b42e36b583fd04d90a4687 (patch) | |
tree | 5f647bcc38c4b05d842570fffaabb97b7be5a4bf /lib/PublicInbox/DS.pm | |
parent | bb7b738bc49558f869a14a2eaecbc5e7f401de51 (diff) | |
download | public-inbox-62bb26d307a106d6c9b42e36b583fd04d90a4687.tar.gz |
This allows callers to avoid creating expensive closures. We no longer pass the `$now' value to callers, as none of the callers used it.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r-- | lib/PublicInbox/DS.pm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index c46b20cb..a3f2e76c 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -95,18 +95,18 @@ sub SetLoopTimeout { return $LoopTimeout = $_[1] + 0; } -=head2 C<< PublicInbox::DS::add_timer( $seconds, $coderef ) >> +=head2 C<< PublicInbox::DS::add_timer( $seconds, $coderef, $arg) >> Add a timer to occur $seconds from now. $seconds may be fractional, but timers are not guaranteed to fire at the exact time you ask for. =cut -sub add_timer ($$) { - my ($secs, $coderef) = @_; +sub add_timer ($$;$) { + my ($secs, $coderef, $arg) = @_; my $fire_time = now() + $secs; - my $timer = [$fire_time, $coderef]; + my $timer = [$fire_time, $coderef, $arg]; if (!@Timers || $fire_time >= $Timers[-1][0]) { push @Timers, $timer; @@ -198,7 +198,7 @@ sub RunTimers { # Run expired timers while (@Timers && $Timers[0][0] <= $now) { my $to_run = shift(@Timers); - $to_run->[1]->($now) if $to_run->[1]; + $to_run->[1]->($to_run->[2]); } # timers may enqueue into nextq: |