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).
=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;