-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdag_executor_fixed_final_test.cpp
More file actions
39 lines (32 loc) · 1.01 KB
/
dag_executor_fixed_final_test.cpp
File metadata and controls
39 lines (32 loc) · 1.01 KB
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
#include "dag_executor_fixed_final.h"
#include <chrono>
#include <iostream>
int main() {
DAGExecutor executor(4);
auto* A = executor.createNode(1, [] {
std::cout << "[A] Start\n";
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::cout << "[A] Done\n";
});
auto* B = executor.createNode(2, [] {
std::cout << "[B] Start\n";
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::cout << "[B] Done\n";
});
auto* C = executor.createNode(3, [] {
std::cout << "[C] Start\n";
std::this_thread::sleep_for(std::chrono::milliseconds(150));
std::cout << "[C] Done\n";
});
A->addSuccessor(B);
A->addSuccessor(C);
try {
std::cout << "🚀 Executing DAG...\n";
executor.executeAndWait(std::chrono::seconds(5));
std::cout << "✅ All done!\n";
} catch (const std::exception& e) {
std::cerr << "❌ Error: " << e.what() << "\n";
return 1;
}
return 0;
}