use strict;
use bytes;
use POSIX ();
-use Time::HiRes ();
use IO::Handle qw();
use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD);
-
+use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
+use parent qw(Exporter);
+our @EXPORT_OK = qw(now);
use warnings;
use PublicInbox::Syscall qw(:epoll);
my $class = shift;
my ($secs, $coderef) = @_;
- my $fire_time = Time::HiRes::time() + $secs;
+ my $fire_time = now() + $secs;
my $timer = bless [$fire_time, $coderef], "PublicInbox::DS::Timer";
}
}
+sub now () { clock_gettime(CLOCK_MONOTONIC) }
+
# runs timers and returns milliseconds for next one, or next event loop
sub RunTimers {
return $LoopTimeout unless @Timers;
- my $now = Time::HiRes::time();
+ my $now = now();
# Run expired timers
while (@Timers && $Timers[0][0] <= $now) {
use IO::Handle;
use IO::Socket;
use Cwd qw/abs_path/;
-use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
STDOUT->autoflush(1);
STDERR->autoflush(1);
-require PublicInbox::DS;
+use PublicInbox::DS qw(now);
require PublicInbox::EvCleanup;
require POSIX;
require PublicInbox::Listener;
PublicInbox::DS->SetPostLoopCallback(sub {
my ($dmap, undef) = @_;
my $n = 0;
- my $now = clock_gettime(CLOCK_MONOTONIC);
+ my $now = now();
foreach my $s (values %$dmap) {
$s->can('busy') or next;
}
}
if ($n) {
- if (($warn + 5) < time) {
+ if (($warn + 5) < now()) {
warn "$$ quitting, $n client(s) left\n";
- $warn = time;
+ $warn = now();
}
unless (defined $proc_name) {
$proc_name = (split(/\s+/, $0))[0];
require PublicInbox::EvCleanup;
use Email::Simple;
use POSIX qw(strftime);
-use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
+PublicInbox::DS->import('now');
use Digest::SHA qw(sha1_hex);
use Time::Local qw(timegm timelocal);
use constant {
r430 => '430 No article with that message-id',
};
-sub now () { clock_gettime(CLOCK_MONOTONIC) };
-
my @OVERVIEW = qw(Subject From Date Message-ID References Xref);
my $OVERVIEW_FMT = join(":\r\n", @OVERVIEW, qw(Bytes Lines)) . ":\r\n";
my $LIST_HEADERS = join("\r\n", @OVERVIEW,