joque
task orchestration library
dag.hpp
Go to the documentation of this file.
1 #pragma once
23 
24 #include "bits/dag.hpp"
25 #include "bits/list.hpp"
26 #include "task.hpp"
27 
28 #include <iosfwd>
29 #include <memory>
30 #include <ranges>
31 #include <string>
32 
33 namespace joque
34 {
35 
36 struct edge_content;
38 
39 struct node_content;
41 
42 enum class ekind : uint8_t
43 {
44  // A after B => A shall be executed after B finishes
45  AFTER,
46  // A invalidated_by B => if B was executed, A is considered out of date
48  // A requires B => A has to be skipped if B failed
49  REQUIRES
50 };
51 
52 std::string_view to_sv( const ekind& e );
53 
55 {
59 };
60 
61 template < ekind Kind, typename Edges >
62 auto filter_edges( Edges& e )
63 {
64  return e | std::views::filter( []( const dag_edge& e ) {
65  return e->kind == Kind;
66  } );
67 }
68 
69 template < typename Node, typename... Args >
70 void add_edge( Node& source, Node& target, Args&&... args )
71 {
72  auto& e =
73  source.out_edges().emplace_front( source, target, std::forward< Args >( args )... );
74  target.in_edges().link_front( e );
75 }
76 
77 enum class inval : uint8_t
78 {
79  VALID,
80  INVALID,
81  UNKNOWN
82 };
83 std::string_view to_sv( const inval& k );
84 
86 {
88  std::string name;
90  const task& t;
91 
94 
96  bool started = false;
99  bool done = false;
101  bool failed = false;
102 };
103 
106 
107 void insert_set( dag& dag, const task_set& ts, const std::string& filter );
108 
109 } // namespace joque
Definition: dag.hpp:47
Definition: dag.hpp:97
Definition: dag.hpp:172
MIT License.
Definition: dag.hpp:27
bool started
Sets to true once the task is scheduled for execution.
Definition: dag.hpp:96
const task & t
Reference to the task.
Definition: dag.hpp:90
std::string name
Full path-name of the task.
Definition: dag.hpp:88
void add_edge(Node &source, Node &target, Args &&... args)
Definition: dag.hpp:70
std::string_view to_sv(const ekind &e)
dag_node & source
Definition: dag.hpp:56
dag_node & target
Definition: dag.hpp:57
ekind
Definition: dag.hpp:43
auto filter_edges(Edges &e)
Definition: dag.hpp:62
inval invalidated
Node validation status.
Definition: dag.hpp:93
void insert_set(dag &dag, const task_set &ts, const std::string &filter)
ekind kind
Definition: dag.hpp:58
inval
Definition: dag.hpp:78
bool failed
Sets to fail if the task failed during execution.
Definition: dag.hpp:101
bool done
Sets to done if the task finished it's execution (correctly or incorrectly)
Definition: dag.hpp:99
Definition: dag.hpp:55
Definition: dag.hpp:86
Single task that should be executed by the system.
Definition: task.hpp:49
A set of tasks that contains either tasks or another sets.
Definition: task.hpp:81