-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.h
More file actions
50 lines (39 loc) · 942 Bytes
/
program.h
File metadata and controls
50 lines (39 loc) · 942 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QObject>
#include <thread>
#include <atomic>
#include <condition_variable>
#include <QLabel>
#include <optional>
#include "ribbon.h"
#include "turing-program/tprog.h"
enum class program_stage : uchar {
WORK,
STEP,
PAUSE,
STOP,
EXIT
};
class program : public QObject
{
Q_OBJECT
public:
explicit program(QObject *parent, ribbon* r, QLabel* lb, std::atomic<bool>&);
~program() noexcept;
void set_program(std::string const&);
void set_stage(program_stage) noexcept;
void thread_main();
std::atomic<int> speed{500};
private:
std::atomic<program_stage> stage_token{program_stage::STOP};
std::condition_variable program_updated;
std::mutex m;
std::optional<tprog> prog{std::nullopt};
bool restart{false};
ribbon* rib;
QLabel* label;
std::atomic<bool>& free_ribbon;
std::thread worker;
};
#endif // PROGRAM_H