forked from wiltchamberian/SunTaskFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.cpp
More file actions
41 lines (33 loc) · 748 Bytes
/
Task.cpp
File metadata and controls
41 lines (33 loc) · 748 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
#include "Task.h"
namespace Sun {
Task::Task(std::function<void()>&& func ,size_t id) {
func_ = func;
id_ = id;
}
size_t Task::getTaskNum() {
size_t res = 0;
for (auto& it : children_) {
res += it->getTaskNum();
}
res += 1;
return res;
}
void Task::addChild(Task* task) {
children_.push_back(task);
task->parent = this;
unfinished_children_num_ += 1;
}
void Task::precede(Task* t) {
this->successors_.push_back(t);
t->dependents_.push_back(this);
t->unfinished_dependents_num_ += 1;
}
void Task::succeed(Task* t) {
t->successors_.push_back(this);
this->dependents_.push_back(t);
this->unfinished_dependents_num_ += 1;
}
void Task::run() {
func_();
}
}