2018-06-22 22:21:20 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2018-06-22 19:10:27 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
2018-06-21 21:41:40 +08:00
|
|
|
|
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-26 21:47:22 +08:00
|
|
|
explicit Worker(TaskManager *parent);
|
2018-06-21 23:44:18 +08:00
|
|
|
public Q_SLOTS:
|
2018-06-26 21:47:22 +08:00
|
|
|
void newContext(Context *);
|
2018-06-22 21:35:07 +08:00
|
|
|
void pack();
|
2018-06-23 22:03:22 +08:00
|
|
|
void budget(double freq);
|
|
|
|
void place(bool timing_driven);
|
2018-06-22 21:35:07 +08:00
|
|
|
void route();
|
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-22 21:35:07 +08:00
|
|
|
void pack_finished(bool status);
|
2018-06-23 22:03:22 +08:00
|
|
|
void budget_finish(bool status);
|
2018-06-22 21:35:07 +08:00
|
|
|
void place_finished(bool status);
|
|
|
|
void route_finished(bool status);
|
|
|
|
void taskCanceled();
|
|
|
|
void taskStarted();
|
|
|
|
void taskPaused();
|
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-26 21:47:22 +08:00
|
|
|
explicit TaskManager();
|
2018-06-21 21:41:40 +08:00
|
|
|
~TaskManager();
|
2018-06-22 18:11:22 +08:00
|
|
|
bool shouldTerminate();
|
|
|
|
void clearTerminate();
|
2018-06-22 18:49:20 +08:00
|
|
|
bool isPaused();
|
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-22 18:49:20 +08:00
|
|
|
void pause_thread();
|
|
|
|
void continue_thread();
|
2018-06-21 23:44:18 +08:00
|
|
|
Q_SIGNALS:
|
2018-06-26 21:47:22 +08:00
|
|
|
void contextChanged(Context *ctx);
|
2018-06-22 18:11:22 +08:00
|
|
|
void terminate();
|
2018-06-22 21:35:07 +08:00
|
|
|
void pack();
|
2018-06-23 22:03:22 +08:00
|
|
|
void budget(double freq);
|
|
|
|
void place(bool timing_driven);
|
2018-06-22 21:35:07 +08:00
|
|
|
void route();
|
|
|
|
|
|
|
|
// redirected signals
|
2018-06-21 21:41:40 +08:00
|
|
|
void log(const std::string &text);
|
2018-06-22 21:35:07 +08:00
|
|
|
void pack_finished(bool status);
|
2018-06-23 22:03:22 +08:00
|
|
|
void budget_finish(bool status);
|
2018-06-22 21:35:07 +08:00
|
|
|
void place_finished(bool status);
|
|
|
|
void route_finished(bool status);
|
|
|
|
void taskCanceled();
|
|
|
|
void taskStarted();
|
|
|
|
void taskPaused();
|
2018-06-22 18:11:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QMutex mutex;
|
|
|
|
bool toTerminate;
|
2018-06-22 18:49:20 +08:00
|
|
|
bool toPause;
|
2018-06-21 21:41:40 +08:00
|
|
|
};
|
|
|
|
|
2018-06-22 19:10:27 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
2018-06-21 21:41:40 +08:00
|
|
|
#endif // WORKER_H
|