mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-07-11 02:16:07 -04:00
Merge branch 'master' into nomerge2
This commit is contained in:
@ -323,6 +323,7 @@ public:
|
||||
bool are_new_jobs_allowed() const {
|
||||
return new_jobs_allowed && !no_threads;
|
||||
}
|
||||
void cancel_all_jobs_for_shutdown();
|
||||
|
||||
unsigned num_queued_jobs() const;
|
||||
|
||||
@ -360,7 +361,7 @@ JobScheduler_impl::~JobScheduler_impl() {
|
||||
{
|
||||
ScopedLock sl(mtx);
|
||||
while(!cpu_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(cpu_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(cpu_job_queue.back(),job_exit_program_exit));
|
||||
cpu_job_queue.pop_back();
|
||||
}
|
||||
while(!cpu_job_queue.empty()) {
|
||||
@ -368,23 +369,27 @@ JobScheduler_impl::~JobScheduler_impl() {
|
||||
cpu_job_queue.pop_back();
|
||||
}
|
||||
while(!summary_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(summary_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(summary_job_queue.back(),job_exit_program_exit));
|
||||
summary_job_queue.pop_back();
|
||||
}
|
||||
while(!io_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(io_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(io_job_queue.back(),job_exit_program_exit));
|
||||
io_job_queue.pop_back();
|
||||
}
|
||||
while(!coordinator_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(coordinator_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(coordinator_job_queue.back(),job_exit_program_exit));
|
||||
coordinator_job_queue.pop_back();
|
||||
}
|
||||
while(!external_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(external_job_queue.back(),job_exit_program_exit));
|
||||
external_job_queue.pop_back();
|
||||
}
|
||||
while(!file_meta_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(file_meta_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(file_meta_job_queue.back(),job_exit_program_exit));
|
||||
file_meta_job_queue.pop_back();
|
||||
}
|
||||
while(!merge_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(merge_job_queue.back(),job_exit_cancelled));
|
||||
exit_set.push_back(std::make_pair(merge_job_queue.back(),job_exit_program_exit));
|
||||
merge_job_queue.pop_back();
|
||||
}
|
||||
}
|
||||
@ -552,6 +557,39 @@ bool JobScheduler_impl::is_reading_file(const BigFile *bf)
|
||||
}
|
||||
|
||||
|
||||
void JobScheduler_impl::cancel_all_jobs_for_shutdown() {
|
||||
ScopedLock sl(mtx);
|
||||
while(!coordinator_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(coordinator_job_queue.back(),job_exit_program_exit));
|
||||
coordinator_job_queue.pop_back();
|
||||
}
|
||||
while(!cpu_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(cpu_job_queue.back(),job_exit_program_exit));
|
||||
cpu_job_queue.pop_back();
|
||||
}
|
||||
while(!summary_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(summary_job_queue.back(),job_exit_program_exit));
|
||||
summary_job_queue.pop_back();
|
||||
}
|
||||
while(!io_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(io_job_queue.back(),job_exit_program_exit));
|
||||
io_job_queue.pop_back();
|
||||
}
|
||||
while(!external_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(external_job_queue.back(),job_exit_program_exit));
|
||||
external_job_queue.pop_back();
|
||||
}
|
||||
while(!file_meta_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(file_meta_job_queue.back(),job_exit_program_exit));
|
||||
file_meta_job_queue.pop_back();
|
||||
}
|
||||
while(!merge_job_queue.empty()) {
|
||||
exit_set.push_back(std::make_pair(merge_job_queue.back(),job_exit_program_exit));
|
||||
merge_job_queue.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned JobScheduler_impl::num_queued_jobs() const
|
||||
{
|
||||
@ -747,6 +785,12 @@ bool JobScheduler::are_new_jobs_allowed() const
|
||||
}
|
||||
|
||||
|
||||
void JobScheduler::cancel_all_jobs_for_shutdown() {
|
||||
if(impl)
|
||||
impl->cancel_all_jobs_for_shutdown();
|
||||
}
|
||||
|
||||
|
||||
unsigned JobScheduler::num_queued_jobs() const
|
||||
{
|
||||
if(impl)
|
||||
|
@ -112,6 +112,8 @@ public:
|
||||
void disallow_new_jobs();
|
||||
bool are_new_jobs_allowed() const;
|
||||
|
||||
void cancel_all_jobs_for_shutdown();
|
||||
|
||||
unsigned num_queued_jobs() const;
|
||||
|
||||
void cleanup_finished_jobs();
|
||||
|
@ -705,6 +705,8 @@ bool Process::shutdown2() {
|
||||
RdbBase::finalizeGlobalIndexThread();
|
||||
finalizeMsg4IncomingThread();
|
||||
|
||||
g_jobScheduler.cancel_all_jobs_for_shutdown();
|
||||
|
||||
static bool s_printed = false;
|
||||
|
||||
// wait for all threads to return
|
||||
|
Reference in New Issue
Block a user