Peano
|
Spawned node. More...
#include <dynamic_task_graph_spawned_node.h>
Public Types | |
enum class | State { Submitted , Spawned , Complete } |
Public Member Functions | |
dynamic_task_graph_spawned_node (const dynamic_task_graph_node &task_specification, dynamic_task_graph &task_graph) | |
Create a new task node in the graph. | |
dynamic_task_graph_spawned_node (const dynamic_task_graph_spawned_node &)=delete | |
You cannot copy a spawned node. | |
void | incoming_task_has_terminated () |
void | run () |
Run the task. | |
Private Attributes | |
std::atomic< State > | _state |
std::function< void()> | _functor |
tbb::spin_mutex | _semaphore |
dynamic_task_graph & | _task_graph |
int | _number_of_in_dependencies |
std::vector< std::shared_ptr< dynamic_task_graph_spawned_node > > | _out_dependency |
Friends | |
class | dynamic_task_graph |
Spawned node.
This class is only used internally within the task graph lib and not to be used directly by users. Users create instances of dynamic_task_graph_node. Once they put this node into a task_graph instance, it is tied to a new instance of spawned_task_graph_node.
As long as a task graph is alive, users might use it to introduce new task dependencies. So we have to ensure that the memory location is absolutely unique. Notably, we may not encounter a situation where a user submits a task A, this task is processed immediately, then creates a task B and a task C which depends on A (but not B). So B may never ever end up at the same memory location as A.
To avoid this, we work exclusively with smart pointers referencing spawned nodes.
Definition at line 46 of file dynamic_task_graph_spawned_node.h.
|
strong |
Enumerator | |
---|---|
Submitted | |
Spawned | |
Complete |
Definition at line 50 of file dynamic_task_graph_spawned_node.h.
tbb::dynamic_task_graph_spawned_node::dynamic_task_graph_spawned_node | ( | const dynamic_task_graph_node & | task_specification, |
dynamic_task_graph & | task_graph ) |
Create a new task node in the graph.
Creating a new task node means that we have to "invert" the edges in the underlying graph: An instance of task_specification knows which task are incoming. For the actual task graph, we need the outgoing tasks.
The default spawned task has one incoming dependency, i.e. is not ready. You have to manually decrease the counter after construction once all dependencies are in place.
Definition at line 11 of file dynamic_task_graph_spawned_node.cpp.
References __TBB_TRACE_TASK_CREATE.
|
delete |
You cannot copy a spawned node.
void tbb::dynamic_task_graph_spawned_node::incoming_task_has_terminated | ( | ) |
Definition at line 24 of file dynamic_task_graph_spawned_node.cpp.
Referenced by tbb::dynamic_task_graph::put().
void tbb::dynamic_task_graph_spawned_node::run | ( | ) |
Run the task.
This is the actual routine which hands the task over to TBB's runtime. The system is allowed to invoke it if and only if the task is ready, i.e. has no pending incoming dependencies anymore.
We work with catch by reference here, as we know that all the task's fields are still alive while we execute the task.
Definition at line 38 of file dynamic_task_graph_spawned_node.cpp.
References __TBB_TRACE_TASK_COMPLETE, __TBB_TRACE_TASK_RUN, and _state().
|
friend |
Definition at line 48 of file dynamic_task_graph_spawned_node.h.
|
private |
Definition at line 119 of file dynamic_task_graph_spawned_node.h.
Referenced by peano4.visualisation.filters.Calculator.Calculator::render().
|
private |
Definition at line 122 of file dynamic_task_graph_spawned_node.h.
Referenced by tbb::dynamic_task_graph::put().
|
private |
Definition at line 123 of file dynamic_task_graph_spawned_node.h.
|
private |
Definition at line 120 of file dynamic_task_graph_spawned_node.h.
Referenced by tbb::dynamic_task_graph::put().
|
private |
Definition at line 118 of file dynamic_task_graph_spawned_node.h.
Referenced by tbb::dynamic_task_graph::wait().
|
private |
Definition at line 121 of file dynamic_task_graph_spawned_node.h.