From 6306663a3b4167edfd5b1fd640233da96fe9e32f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 27 Jun 2019 21:21:03 +0000 Subject: ds: move requeue logic over from NNTP We'll be reusing requeue in other places to reduce trips to the kernel to retrieve "hot" descriptors. --- lib/PublicInbox/DS.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/PublicInbox/DS.pm') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 28240843..9f245347 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -37,6 +37,8 @@ use Errno qw(EAGAIN EINVAL EEXIST); use Carp qw(croak confess carp); require File::Spec; +my $nextt; # timer for next_tick +my $nextq = []; # queue for next_tick our ( %DescriptorMap, # fd (num) -> PublicInbox::DS object $Epoll, # Global epoll fd (or DSKQXS ref) @@ -594,6 +596,18 @@ sub shutdn ($) { } } +sub next_tick () { + $nextt = undef; + my $q = $nextq; + $nextq = []; + $_->event_step for @$q; +} + +sub requeue ($) { + push @$nextq, $_[0]; + $nextt ||= PublicInbox::EvCleanup::asap(*next_tick); +} + package PublicInbox::DS::Timer; # [$abs_float_firetime, $coderef]; sub cancel { -- cgit v1.2.3-24-ge0c7