-
Notifications
You must be signed in to change notification settings - Fork 0
/
BackgroundInputProcessor.h
47 lines (34 loc) · 968 Bytes
/
BackgroundInputProcessor.h
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
37
38
39
40
41
42
43
44
45
46
47
#ifndef BACKGROUNDINPUTPROCESSOR_H
#define BACKGROUNDINPUTPROCESSOR_H
#include "InputParser.h"
#include "Item.h"
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include <atomic>
class BackgroundInputProcessor : public QThread {
Q_OBJECT
explicit BackgroundInputProcessor(QObject* parent = nullptr);
public:
static BackgroundInputProcessor* getInstance();
void processInput(const QString& input);
bool isProcessing() const;
void setIsProcessing(bool isProcessing);
void stop(int waitingTime = 0);
signals:
void processingStarted();
void processingFinished(QList<QObject*> items);
public slots:
protected:
virtual void run();
private:
QList<QObject*> process();
InputParser* parser = nullptr;
bool _isProcessing = true;
QWaitCondition condition;
QMutex mutex;
QString lastInput;
bool queued = false;
std::atomic<bool> isWaiting;
};
#endif // BACKGROUNDINPUTPROCESSOR_H