diff options
author | Eric Wong <e@80x24.org> | 2016-07-09 04:51:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-07-09 04:52:13 +0000 |
commit | 63d2e98ce28ddfefeac8bfdac409eae5efc03a9f (patch) | |
tree | 4dec15e825511818f21262f3174f0fcb6b0cae55 /lib/PublicInbox/EvCleanup.pm | |
parent | acd3a41f52167b8e41cf34ab8164a9dfb5ef9c5c (diff) | |
download | public-inbox-63d2e98ce28ddfefeac8bfdac409eae5efc03a9f.tar.gz |
EvCleanup::asap events are not guaranteed to run after Danga::Socket closes sockets at the event loop. Thus we must use slower Danga::Socket timers which are guaranteed to run at the end of the event loop.
Diffstat (limited to 'lib/PublicInbox/EvCleanup.pm')
-rw-r--r-- | lib/PublicInbox/EvCleanup.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/PublicInbox/EvCleanup.pm b/lib/PublicInbox/EvCleanup.pm index 61837b89..2b77c617 100644 --- a/lib/PublicInbox/EvCleanup.pm +++ b/lib/PublicInbox/EvCleanup.pm @@ -9,6 +9,7 @@ use base qw(Danga::Socket); use fields qw(rd); my $singleton; my $asapq = [ [], undef ]; +my $nextq = [ [], undef ]; my $laterq = [ [], undef ]; sub once_init () { @@ -30,6 +31,7 @@ sub _run_all ($) { } sub _run_asap () { _run_all($asapq) } +sub _run_next () { _run_all($nextq) } sub _run_later () { _run_all($laterq) } # Called by Danga::Socket @@ -51,6 +53,12 @@ sub asap ($) { $asapq->[1] ||= _asap_timer(); } +sub next_tick ($) { + my ($cb) = @_; + push @{$nextq->[0]}, $cb; + $nextq->[1] ||= Danga::Socket->AddTimer(0, *_run_next); +} + sub later ($) { my ($cb) = @_; push @{$laterq->[0]}, $cb; @@ -59,6 +67,7 @@ sub later ($) { END { _run_asap(); + _run_next(); _run_later(); } |