-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.hpp
65 lines (52 loc) · 1.07 KB
/
task.hpp
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
#include <bits/stdc++.h>
using namespace std;
class Subflow;
class Task {
// friend class graph;
// friend class executor;
public:
int id;
vector<Task*> successor;
vector<Task*> predecessor;
atomic<int> dependency;
Subflow* subflow;
function<void()> fun;
bool operator <(const Task& rhs) const
{
return id < rhs.id;
}
void execute_task(){
(this->fun)();
}
void attach(Subflow* sub){
this->subflow = sub;
}
void detach(){
this->subflow = NULL;
}
void succeed(vector<Task*> input){
for(auto task: input){
this->successor.push_back(task);
task->predecessor.push_back(this);
this->predecessor.push_back(task);
task->successor.push_back(this);
}
}
void precede(vector<Task*> input){
for(auto task: input){
this->dependency++;
this->predecessor.push_back(task);
task->successor.push_back(this);
}
}
};
// void fun(){
// cout<<"Hello";
// }
// int main(){
// Task A = Task();
// Taskflow An = Taskflow();
// An.add(A);
// A.fun = bind(&fun);
// A.execute_task();
// }