Removed async parser related functionalities from Craplog
This commit is contained in:
Valentino Orlandi 2024-01-21 14:43:33 +01:00
parent 837ef418b4
commit 2bb706b766
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
2 changed files with 1 additions and 71 deletions

View File

@ -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 <QUrl>
#include <QPainter>
@ -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<std::mutex> 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;

View File

@ -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;
//////////////////////