- my $max = $opt->{jobs} || scalar(@q);
- $ibx->with_umask(sub {
- my $im = $ibx->importer(0);
- $im->lock_acquire;
-
- # fine-grained locking if we prepare for reindex
- if (!$opt->{-coarse_lock}) {
- prepare_reindex($ibx, $im, $reindex);
- $im->lock_release;
- }
+ ($tmp, \@queue);
+}
+
+sub check_compact () { runnable_or_die($XAPIAN_COMPACT) }
+
+sub _run { # with_umask callback
+ my ($ibx, $cb, $opt) = @_;
+ my $im = $ibx->can('importer') ? $ibx->importer(0) : undef;
+ ($im // $ibx)->lock_acquire;
+ my ($tmp, $queue) = prepare_run($ibx, $opt);
+
+ # fine-grained locking if we prepare for reindex
+ if (!$opt->{-coarse_lock}) {
+ prepare_reindex($ibx, $opt);
+ ($im // $ibx)->lock_release;
+ }
+
+ $ibx->cleanup if $ibx->can('cleanup');
+ process_queue($queue, $cb, $opt);
+ ($im // $ibx)->lock_acquire if !$opt->{-coarse_lock};
+ commit_changes($ibx, $im, $tmp, $opt);
+}