-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremote_execution_manager.h
84 lines (61 loc) · 1.49 KB
/
remote_execution_manager.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef REMOTE_EXECUTION_MANAGER_H
#define REMOTE_EXECUTION_MANAGER_H
#include <vector>
#include <queue>
#include <memory>
#include <string>
#include <atomic>
#include <future>
#include <mutex>
using std::vector;
using std::queue;
using std::shared_ptr;
using std::string;
using std::atomic_uint;
using std::future;
using std::recursive_mutex;
class RemoteExecutionManager {
public:
struct Machine {
Machine(string &name, uint numberSlots): name(name), numberSlots(numberSlots) {};
string name;
atomic_uint numberSlots;
};
struct Dispatch {
Dispatch(Machine *machine, string &filename, uint line): machine(machine), filename(filename), line(line) {};
Machine *machine;
string filename;
uint line;
pid_t pid;
int exit_value;
};
enum WaitMode {
NoWait,
WaitFirst,
WaitFirstFaulty
};
enum ClearingResult {
Sat,
Unsat,
Done
};
private:
vector<Machine *> remote_machines;
vector<Dispatch *> remote_dispatches;
vector<Dispatch *> delayed_dispatches;
vector<future<bool>> remote_dispatch_results;
uint search_offset;
recursive_mutex serializer;
public:
RemoteExecutionManager();
virtual ~RemoteExecutionManager();
void dispatch(string filename, uint line);
ClearingResult clear_dispatches();
void kill_dispatches();
private:
void add_machine(string machine_name, uint numberSlots);
int find_machine();
void dispatch(Dispatch *dispatch);
void run_local(char *const command_line[], pid_t *pid, int *exit_value);
};
#endif /* REMOTE_EXECUTION_MANAGER_H */