diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:05 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:25 +0000 |
commit | 2f9aea4ecb6208955144e8a2290d747a4ff9c966 (patch) | |
tree | 51abab889f239363dd8305101e131f11858b7fe4 /lib/PublicInbox/DS.pm | |
parent | 860c7e13d31390dc16c2cce813e4887f12e76731 (diff) | |
download | public-inbox-2f9aea4ecb6208955144e8a2290d747a4ff9c966.tar.gz |
We rely on immediate timers often, so we can avoid the overhead of an extra subroutine call to retrieve the monotonic time (and a sometimes-system call on some platforms).
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r-- | lib/PublicInbox/DS.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index e7db2034..ed04feb5 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -113,8 +113,13 @@ Returns a timer object which you can call C<< $timer->cancel >> on if you need t =cut sub AddTimer { - my $class = shift; - my ($secs, $coderef) = @_; + my ($class, $secs, $coderef) = @_; + + if (!$secs) { + my $timer = bless([0, $coderef], 'PublicInbox::DS::Timer'); + unshift(@Timers, $timer); + return $timer; + } my $fire_time = now() + $secs; |