-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterface.h
48 lines (39 loc) · 1.31 KB
/
interface.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
48
#ifndef __INTERFACE_H__
#define __INTERFACE_H__
#include <climits>
#include <mutex>
#include <thread>
#include <condition_variable>
#include <csignal>
#define MILLISEC 800
#define SIG_PRIM_STEP_FINISHED 0
#define SIG_FIB_STEP_FINISHED 1
#define SIG_FINISHED_ALL 2
#define SIG_MIN_EXTRACTED 3
#define SIG_MST_UPDATED 4
#define SIG_NEXT_LINE 5
#define SIG_ERROR 6
#define GET_LINE(l) \
do { \
shared_mtx.lock(); \
l = cur_line; \
shared_mtx.unlock(); \
} while (0)
#define NEXT_LINE(l) \
do { \
shared_mtx.lock(); \
cur_line = l; \
shared_mtx.unlock(); \
} while (0)
typedef enum {RUN,STEP} runMode;
extern unsigned char speed; // algorithm speed limiter
extern std::condition_variable cv;
extern bool ready; // signalizes if GUI ready for next update
extern bool sim_terminate;
extern unsigned cur_line; // signalizes current line of pseudo-algorithm
extern runMode mode; // which mode of execution we do prefer
extern std::mutex shared_mtx; // protects GUI speed settings
extern std::mutex uni_mtx; // used to acquire lock on conditional variable
void sigEvent(int sig, unsigned u=UINT_MAX, unsigned v=UINT_MAX);
void syncGUI(int sig, unsigned u=UINT_MAX, unsigned v=UINT_MAX);
#endif // __INTERFACE_H__