2018-06-21 21:41:40 +08:00
|
|
|
#ifndef WORKER_H
|
|
|
|
#define WORKER_H
|
|
|
|
|
2018-06-22 18:11:22 +08:00
|
|
|
#include <QMutex>
|
2018-06-21 21:41:40 +08:00
|
|
|
#include <QThread>
|
2018-06-21 23:44:18 +08:00
|
|
|
#include "nextpnr.h"
|
2018-06-21 21:41:40 +08:00
|
|
|
|
|
|
|
// FIXME
|
|
|
|
USING_NEXTPNR_NAMESPACE
|
|
|
|
|
2018-06-22 18:11:22 +08:00
|
|
|
class TaskManager;
|
|
|
|
|
2018-06-21 21:41:40 +08:00
|
|
|
class Worker : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-06-21 23:44:18 +08:00
|
|
|
public:
|
2018-06-22 18:11:22 +08:00
|
|
|
Worker(Context *ctx, TaskManager *parent);
|
2018-06-21 23:44:18 +08:00
|
|
|
public Q_SLOTS:
|
2018-06-21 21:41:40 +08:00
|
|
|
void parsejson(const std::string &filename);
|
2018-06-21 23:44:18 +08:00
|
|
|
Q_SIGNALS:
|
2018-06-21 21:41:40 +08:00
|
|
|
void log(const std::string &text);
|
2018-06-21 23:44:18 +08:00
|
|
|
|
|
|
|
private:
|
2018-06-21 21:41:40 +08:00
|
|
|
Context *ctx;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TaskManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
QThread workerThread;
|
2018-06-21 23:44:18 +08:00
|
|
|
|
|
|
|
public:
|
2018-06-21 21:41:40 +08:00
|
|
|
TaskManager(Context *ctx);
|
|
|
|
~TaskManager();
|
2018-06-22 18:11:22 +08:00
|
|
|
bool shouldTerminate();
|
|
|
|
void clearTerminate();
|
2018-06-21 23:44:18 +08:00
|
|
|
public Q_SLOTS:
|
2018-06-21 21:41:40 +08:00
|
|
|
void info(const std::string &text);
|
2018-06-22 18:11:22 +08:00
|
|
|
void terminate_thread();
|
2018-06-21 23:44:18 +08:00
|
|
|
Q_SIGNALS:
|
2018-06-22 18:11:22 +08:00
|
|
|
void terminate();
|
2018-06-21 21:41:40 +08:00
|
|
|
void parsejson(const std::string &);
|
|
|
|
void log(const std::string &text);
|
2018-06-22 18:11:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QMutex mutex;
|
|
|
|
bool toTerminate;
|
2018-06-21 21:41:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WORKER_H
|