public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob be6672edcdb09d0db6f37f65b1baa7798fe247ce 690 bytes (raw)
$ git show p516-leak:lib/PublicInbox/EvCleanup.pm	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

# event cleanups (for PublicInbox::DS)
package PublicInbox::EvCleanup;
use strict;
use warnings;
require PublicInbox::DS;

# this only runs under public-inbox-{httpd/nntpd}, not generic PSGI servers
my $ENABLED;
sub enabled { $ENABLED }
sub enable { $ENABLED = 1 }
my $laterq = [ [], undef ];

sub _run_later () {
	my $run = $laterq->[0];
	$laterq->[0] = [];
	$laterq->[1] = undef;
	$_->() foreach @$run;
}

sub later ($) {
	my ($cb) = @_;
	push @{$laterq->[0]}, $cb;
	$laterq->[1] ||= PublicInbox::DS->AddTimer(60, *_run_later);
}

END { _run_later() }
1;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git