From 2bb706b7667f5d55da0e7f076e9d7985ec3d245a Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 21 Jan 2024 14:43:33 +0100 Subject: [PATCH] Update Removed async parser related functionalities from Craplog --- logdoctor/modules/craplog/craplog.cpp | 67 +-------------------------- logdoctor/modules/craplog/craplog.h | 5 -- 2 files changed, 1 insertion(+), 71 deletions(-) diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index 04a8203c..a9a936d2 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -17,7 +17,6 @@ #include "modules/craplog/modules/logs.h" #include "modules/craplog/modules/workers/lister.h" #include "modules/craplog/modules/workers/parser.h" -#include "modules/craplog/modules/workers/parser_async.h" #include #include @@ -845,19 +844,6 @@ void Craplog::showWorkerDialog( const WorkerDialog dialog_type, const QStringLis } } -bool Craplog::shouldWorkAsync() const -{ - const size_t n_log_files{ this->log_files_to_use.size() }; - const size_t average_size{ - std::accumulate( this->logs_list.cbegin(), this->logs_list.cend(), 0ul, - []( size_t sum, const LogFile& lf ) - { return lf.isSelected() ? sum+lf.size() : sum; }) - / n_log_files - }; - return (average_size > 1'048'576ul && n_log_files > 1) - || n_log_files > 150ul; -} - void Craplog::startWorking() { std::unique_lock lock( this->mutex ); @@ -869,11 +855,7 @@ void Craplog::startWorking() this->warnlisted_size = 0ul; this->blacklisted_size = 0ul; // hire a worker - if ( this->shouldWorkAsync() ) { - this->hireAsyncWorker(); - } else { - this->hireWorker(); - } + this->hireWorker(); } void Craplog::hireWorker() const { @@ -922,53 +904,6 @@ void Craplog::hireWorker() const // make the worker work worker_thread->start(); } -void Craplog::hireAsyncWorker() const -{ - CraplogParserAsync* worker{ new CraplogParserAsync( - this->current_WS, - this->dialogs_level, - this->db_stats_path, - this->db_hashes_path, - this->logs_formats.at( this->current_WS ), - this->blacklists.at( this->current_WS ), - this->warnlists.at( this->current_WS ), - this->log_files_to_use - ) }; - QThread* worker_thread{ new QThread() }; - worker->moveToThread( worker_thread ); - // start the worker - connect( worker_thread, &QThread::started, - worker, &CraplogParserAsync::work ); - // worker started parsing - connect( worker, &CraplogParserAsync::startedParsing, - this, &Craplog::workerStartedParsing ); - // worker finished parsing - connect( worker, &CraplogParserAsync::finishedParsing, - this, &Craplog::workerFinishedParsing ); - // receive performance data - connect( worker, &CraplogParserAsync::perfData, - this, &Craplog::updatePerfData ); - // receive chart data, only received when worker has done - connect( worker, &CraplogParserAsync::chartData, - this, &Craplog::updateChartData ); - // show a dialog - connect( worker, &CraplogParserAsync::showDialog, - this, &Craplog::showWorkerDialog ); - // worker finished its career - connect( worker, &CraplogParserAsync::done, - this, &Craplog::stopWorking ); - // plan deleting the worker - connect( worker, &CraplogParserAsync::retire, - worker, &CraplogParserAsync::deleteLater ); - // quit the thread - connect( worker, &CraplogParserAsync::retire, - worker_thread, &QThread::quit ); - // plan deleting the thread - connect( worker_thread, &QThread::finished, - worker_thread, &QThread::deleteLater ); - // make the worker work - worker_thread->start(); -} void Craplog::stopWorking( const bool successful ) { this->db_edited = successful; diff --git a/logdoctor/modules/craplog/craplog.h b/logdoctor/modules/craplog/craplog.h index 6899693e..3d97cb22 100644 --- a/logdoctor/modules/craplog/craplog.h +++ b/logdoctor/modules/craplog/craplog.h @@ -485,11 +485,6 @@ private: //! Hires a worker to parse the selected logs void hireWorker() const; - //! Hires a worker to parse the selected logs, asynchronously - void hireAsyncWorker() const; - - //! Defines whether it's worth it working async or not - bool shouldWorkAsync() const; //////////////////////