-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptodispatcher.cpp
More file actions
36 lines (32 loc) · 981 Bytes
/
cryptodispatcher.cpp
File metadata and controls
36 lines (32 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "cryptodispatcher.h"
#include <QDebug>
CryptoDispatcher::CryptoDispatcher(CryptoQueue *q)
{
this->queue = q;
this->algo = new SimpleSubstitutioner();
}
CryptoDispatcher::~CryptoDispatcher()
{
this->appRunning = false;
delete this->algo;
}
void CryptoDispatcher::run()
{
while (this->appRunning) {
while (this->runMode) {
if (this->runningThreads < 16 && this->queue->length() != 0) {
this->runningThreads++;
this->dispatch();
}
}
}
}
void CryptoDispatcher::dispatch()
{
QString inPath = this->queue->removeFirst();
CryptoWorker *workerThread = new CryptoWorker(this->encryption, algo, inPath, this->outDir);
QObject::connect(workerThread, &CryptoWorker::algorithmEnd, this, &CryptoDispatcher::threadEnd);
QObject::connect(workerThread, &CryptoWorker::finished, workerThread, &QObject::deleteLater);
workerThread->start();
this->runningThreads--;
}