about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:39 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit48180dbb004b5f59b2e80613b6fa2e5e869316f1 (patch)
tree95f8021050131910f01072d241334eb39e24912e /lib/PublicInbox/Config.pm
parent85993613eae14f63785e9c75cc41358e603c0bbf (diff)
downloadpublic-inbox-48180dbb004b5f59b2e80613b6fa2e5e869316f1.tar.gz
This will be used to prevent reloading a giant config with
tens/hundreds of thousands of inboxes from blocking the event
loop.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 458f29b2..c18c9c75 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -99,6 +99,21 @@ sub each_inbox {
         }
 }
 
+sub iterate_start {
+        my ($self, $cb, $arg) = @_;
+        my $i = 0;
+        $self->{-iter} = [ \$i, $cb, $arg ];
+}
+
+# for PublicInbox::DS::next_tick
+sub event_step {
+        my ($self) = @_;
+        my ($i, $cb, $arg) = @{$self->{-iter}};
+        my $section = $self->{-section_order}->[$$i++];
+        delete($self->{-iter}) unless defined($section);
+        $cb->($self, $section, $arg);
+}
+
 sub lookup_newsgroup {
         my ($self, $ng) = @_;
         _lookup_fill($self, '-by_newsgroup', lc($ng));