11#pragma once
22
3- #include " ../threadpool/threadpool.hpp"
4- #include " flow_builder.hpp"
3+ #include " task.hpp"
54#include " framework.hpp"
65
76namespace tf {
87
9- // Class: BasicTaskflow
10- // template argument E : executor, the threadpool implementation
8+ /* * @class BasicTaskflow
9+ *
10+ * @brief The base class to derive a taskflow class
11+ *
12+ * @tparam E: executor type to use in this taskflow
13+ *
14+ * This class is the base class to derive a taskflow class.
15+ *
16+ */
1117template <template <typename ...> typename E>
1218class BasicTaskflow : public FlowBuilder {
1319
@@ -32,35 +38,112 @@ class BasicTaskflow : public FlowBuilder {
3238 public:
3339
3440 using Executor = E<Closure>;
35-
41+
42+ /* *
43+ @brief construct the taskflow with @std_thread_hardware_concurrency worker threads
44+ */
3645 explicit BasicTaskflow ();
37- explicit BasicTaskflow (unsigned );
38- explicit BasicTaskflow (std::shared_ptr<Executor>);
46+
47+ /* *
48+ @brief construct the taskflow with N worker threads
49+ */
50+ explicit BasicTaskflow (unsigned N);
51+
52+ /* *
53+ @brief construct the taskflow with a given executor
54+ */
55+ explicit BasicTaskflow (std::shared_ptr<Executor> executor);
56+
57+ /* *
58+ @brief destruct the taskflow
3959
60+ Destructing a taskflow object will first wait for all running topologies to finish
61+ and then clean up all associated data storages.
62+ */
4063 ~BasicTaskflow ();
4164
65+ /* *
66+ @brief share ownership of the executor associated with this taskflow object
67+
68+ @return a @std_shared_ptr of the executor
69+ */
4270 std::shared_ptr<Executor> share_executor ();
43-
71+
72+ /* *
73+ @brief dispatch the present graph to threads and return immediately
74+
75+ @return a @std_shared_future to access the execution status of the dispatched graph
76+ */
4477 std::shared_future<void > dispatch ();
78+
79+ /* *
80+ @brief dispatch the present graph to threads and run a callaback when the graph completes
4581
82+ @return a @std_shared_future to access the execution status of the dispatched graph
83+ */
4684 template <typename C>
4785 std::shared_future<void > dispatch (C&&);
48-
86+
87+ /* *
88+ @brief dispatch the present graph to threads and return immediately
89+ */
4990 void silent_dispatch ();
91+
92+ /* *
93+ @brief dispatch the present graph to threads and run a callback when the graph completes
5094
95+ @param callable a callable object to execute on completion
96+ */
5197 template <typename C>
52- void silent_dispatch (C&&);
53-
98+ void silent_dispatch (C&& callable);
99+
100+ /* *
101+ @brief dispatch the present graph to threads and wait for all topologies to complete
102+ */
54103 void wait_for_all ();
104+
105+ /* *
106+ @brief wait for all running topologies to complete and clean them up
107+ */
55108 void wait_for_topologies ();
56- void dump (std::ostream&) const ;
57- void dump_topologies (std::ostream&) const ;
109+
110+ /* *
111+ @brief dump the present task dependency graph to a @std_ostream in DOT format
112+
113+ @param ostream a @std_ostream target
114+ */
115+ void dump (std::ostream& ostream) const ;
116+
117+ /* *
118+ @brief dump the present topologies to a @std_ostream in DOT format
58119
120+ @param ostream a @std_ostream target
121+ */
122+ void dump_topologies (std::ostream& ostream) const ;
123+
124+ /* *
125+ @brief return the number of nodes in the present task dependency graph
126+ */
59127 size_t num_nodes () const ;
128+
129+ /* *
130+ @brief return the number of worker threads
131+ */
60132 size_t num_workers () const ;
61- size_t num_topologies () const ;
62133
134+ /* *
135+ @brief return the number of existing topologies
136+ */
137+ size_t num_topologies () const ;
138+
139+ /* *
140+ @brief dump the present task dependency graph in DOT format to a @std_string
141+ */
63142 std::string dump () const ;
143+
144+ /* *
145+ @brief dump the existing topologies in DOT format to a @std_string
146+ */
64147 std::string dump_topologies () const ;
65148
66149 private:
0 commit comments