17 #ifndef __TBB_flow_graph_impl_H 18 #define __TBB_flow_graph_impl_H 20 #include "../tbb_stddef.h" 22 #include "../task_arena.h" 23 #include "../flow_graph_abstractions.h" 25 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 26 #include "../concurrent_priority_queue.h" 31 #if TBB_DEPRECATED_FLOW_ENQUEUE 32 #define FLOW_SPAWN(a) tbb::task::enqueue((a)) 34 #define FLOW_SPAWN(a) tbb::task::spawn((a)) 37 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 38 #define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr ) expr 39 #define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority ) , priority 40 #define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1, priority 42 #define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr ) 43 #define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority ) 44 #define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1 45 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 52 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 58 namespace interface10 {
62 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 78 template <
typename GraphContainerType,
typename GraphNodeType>
100 if (
this != &other) {
161 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 177 __TBB_ASSERT_EX( result,
"Number of critical tasks for scheduler and tasks" 178 " in graph's priority queue mismatched" );
180 "Incorrect task submitted to graph priority queue" );
182 "Tasks from graph's priority queue must have priority" );
199 template<
typename Body >
218 template<
typename Receiver,
typename Body >
276 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 277 void set_name(
const char *
name);
301 template< typename Receiver, typename Body >
302 void run(Receiver &r, Body body) {
304 task* rtask =
new (task::allocate_additional_child_of(*
root_task()))
313 template<
typename Body >
327 #if TBB_USE_EXCEPTIONS 332 #if TBB_USE_EXCEPTIONS 358 template<
typename C,
typename N>
403 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 413 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 414 template<
typename Input,
typename Output,
typename Policy,
typename Allocator>
425 template<
typename C,
typename N>
435 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 436 virtual void set_name(
const char *
name) = 0;
439 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 440 virtual void extract() = 0;
473 task* task_to_spawn = &arena_task;
474 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 476 graph_task* t = static_cast<graph_task*>(&arena_task);
501 #endif // __TBB_flow_graph_impl_H
reference operator*() const
Dereference.
graph_iterator & operator++()
Pre-increment.
bool operator==(const graph_iterator &other) const
Equality.
virtual void reset_node(reset_flags f=rf_reset_protocol)=0
void release_wait() __TBB_override
Deregisters an external entity that may have interacted with the graph.
void activate_graph(graph &g)
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
~graph()
Destroys the graph.
internal::graph_task_priority_queue_t my_priority_queue
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
unsigned int node_priority_t
void prepare_task_arena(bool reinit=false)
GraphContainerType * my_graph
void run(Receiver &r, Body body)
Spawns a task that runs a body and puts its output to a specific receiver.
Used to form groups of tasks.
uintptr_t traits() const
Returns the context's trait.
Base class for types that should not be copied or assigned.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
graph_iterator operator++(int)
Post-increment.
tbb::task * root_task()
Returns the root task of the graph.
bool operator!=(const graph_iterator &other) const
Inequality.
bool operator()(const graph_task *left, const graph_task *right)
Base class for user-defined tasks.
Concurrent priority queue.
task * execute() __TBB_override
Should be overridden by derived classes.
run_and_put_task(Receiver &r, Body &body)
void wait_for_all()
Wait until graph is idle and decrement_wait_count calls equals increment_wait_count calls.
iterator begin()
start iterator
void execute_in_graph_arena(graph &g, F &f)
Executes custom functor inside graph arena.
The base of all graph nodes.
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
A lock that occupies a single byte.
iterator end()
end iterator
Base class for types that should not be assigned.
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
Pure virtual template classes that define interfaces for async communication.
static tbb::task *const SUCCESSFULLY_ENQUEUED
bool try_pop(reference elem)
Gets a reference to and removes highest priority element.
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
tbb::spin_mutex nodelist_mutex
void run(Body body)
Spawns a task that runs a function object.
void add_task_to_graph_reset_list(graph &g, tbb::task *tp)
graph_iterator(const graph_iterator &other)
Copy constructor.
bool is_graph_active(graph &g)
Tag class used to indicate the "attaching" constructor.
void increment_wait_count()
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
graph_task(node_priority_t node_priority=no_priority)
graph()
Constructs a graph with isolated task_group_context.
Base class for tasks generated by graph nodes.
void remove_node(graph_node *n)
void reserve_wait() __TBB_override
Used to register that an external entity may still interact with the graph.
tbb::task_arena * my_task_arena
priority_task_selector(graph_task_priority_queue_t &priority_queue)
#define __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
tbb::concurrent_priority_queue< graph_task *, graph_task_comparator > graph_task_priority_queue_t
graph_iterator()
Default constructor.
bool is_cancelled()
return status of graph execution
void make_critical(task &t)
static const node_priority_t no_priority
tbb::task * graph_root_task
graph_node * my_nodes_last
std::list< tbb::task * > task_list_type
graph_iterator & operator=(const graph_iterator &other)
Assignment.
void push(const_reference elem)
Pushes elem onto the queue, increasing capacity of queue if necessary.
spawn_functor(tbb::task &t)
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
tbb::task_group_context * my_context
graph_iterator< const graph, const graph_node > const_iterator
void register_node(graph_node *n)
const GraphNodeType & const_reference
wait_functor(tbb::task *t)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
const_iterator cbegin() const
start const iterator
const_iterator cend() const
end const iterator
void decrement_wait_count()
graph_iterator< graph, graph_node > iterator
task_list_type my_reset_task_list
graph_task_priority_queue_t & my_priority_queue
internal::return_type_or_void< F >::type execute(F &f)
std::forward_iterator_tag iterator_category
void reset(reset_flags f=rf_reset_protocol)
void set_ref_count(int count)
Set reference count.
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
pointer operator->() const
Dereference.
GraphNodeType & reference
run_task(Body &body, node_priority_t node_priority=no_priority)
void deactivate_graph(graph &g)
A functor that spawns a task.
virtual task * execute()=0
Should be overridden by derived classes.
void initialize()
Forces allocation of the resources for the task_arena as specified in constructor arguments.