21 #ifndef __TBB_flow_graph_impl_H 22 #define __TBB_flow_graph_impl_H 24 #include "../tbb_stddef.h" 26 #include "../task_arena.h" 27 #include "../flow_graph_abstractions.h" 29 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 30 #include "../concurrent_priority_queue.h" 35 #if TBB_DEPRECATED_FLOW_ENQUEUE 36 #define FLOW_SPAWN(a) tbb::task::enqueue((a)) 38 #define FLOW_SPAWN(a) tbb::task::spawn((a)) 41 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 42 #define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr ) expr 43 #define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority ) , priority 44 #define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1, priority 46 #define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr ) 47 #define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority ) 48 #define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1 49 #endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 56 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 62 namespace interface10 {
66 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 82 template <
typename GraphContainerType,
typename GraphNodeType>
99 my_graph(other.my_graph), current_node(other.current_node)
104 if (
this != &other) {
112 reference operator*()
const;
115 pointer operator->()
const;
146 void internal_forward();
165 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 167 bool operator()(
const graph_task* left,
const graph_task* right) {
177 : my_priority_queue(priority_queue) {}
179 graph_task* t = NULL;
180 bool result = my_priority_queue.try_pop(t);
181 __TBB_ASSERT_EX( result,
"Number of critical tasks for scheduler and tasks" 182 " in graph's priority queue mismatched" );
184 "Incorrect task submitted to graph priority queue" );
186 "Tasks from graph's priority queue must have priority" );
203 template<
typename Body >
209 ) : graph_task(node_priority),
222 template<
typename Receiver,
typename Body >
227 tbb::task *res = my_receiver.try_put_task(my_body());
257 my_task_arena->terminate();
261 __TBB_ASSERT(my_task_arena == NULL,
"task arena is not NULL");
264 if (!my_task_arena->is_active())
265 my_task_arena->initialize();
266 __TBB_ASSERT(my_task_arena->is_active(),
"task arena is not active");
280 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 281 void set_name(
const char *
name);
305 template<
typename Receiver,
typename Body >
306 void run(Receiver &r, Body body) {
308 task* rtask =
new (task::allocate_additional_child_of(*
root_task()))
317 template<
typename Body >
329 caught_exception =
false;
331 #if TBB_USE_EXCEPTIONS 335 cancelled = my_context->is_group_execution_cancelled();
336 #if TBB_USE_EXCEPTIONS 339 my_root_task->set_ref_count(1);
341 caught_exception =
true;
351 my_root_task->set_ref_count(1);
362 template<
typename C,
typename N>
375 const_iterator
begin()
const;
377 const_iterator
end()
const;
379 const_iterator cbegin()
const;
381 const_iterator cend()
const;
407 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 417 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 418 template<
typename Input,
typename Output,
typename Policy,
typename Allocator>
429 template<
typename C,
typename N>
439 #if TBB_PREVIEW_FLOW_GRAPH_TRACE 440 virtual void set_name(
const char *
name) = 0;
443 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION 444 virtual void extract() = 0;
477 task* task_to_spawn = &arena_task;
478 #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES 480 graph_task* t =
static_cast<graph_task*
>(&arena_task);
505 #endif // __TBB_flow_graph_impl_H bool operator!=(const graph_iterator &other) const
Inequality.
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 __itt_timestamp end
spawn_functor(tbb::task &t)
bool operator==(const cache_aligned_allocator< T > &, const cache_aligned_allocator< U > &)
static tbb::task *const SUCCESSFULLY_ENQUEUED
void run(Body body)
Spawns a task that runs a function object.
void add_task_to_graph_reset_list(graph &g, tbb::task *tp)
internal::return_type_or_void< F >::type execute(F &f)
bool operator()(const graph_task *left, const graph_task *right)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
#define __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
Base class for types that should not be assigned.
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
std::forward_iterator_tag iterator_category
tbb::task_group_context * my_context
tbb::spin_mutex nodelist_mutex
void run(Receiver &r, Body body)
Spawns a task that runs a body and puts its output to a specific receiver.
graph_node * my_nodes_last
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
void decrement_wait_count()
graph_iterator(const graph_iterator &other)
Copy constructor.
Concurrent priority queue.
void increment_wait_count()
The base of all graph nodes.
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert ...
Pure virtual template classes that define interfaces for async communication.
graph_iterator< graph, graph_node > iterator
const GraphNodeType & const_reference
wait_functor(tbb::task *t)
graph_iterator< const graph, const graph_node > const_iterator
static const node_priority_t no_priority
unsigned int node_priority_t
run_task(Body &body, node_priority_t node_priority=no_priority)
tbb::task * root_task()
Returns the root task of the graph.
void activate_graph(graph &g)
graph_iterator operator++(int)
Post-increment.
void push(const_reference elem)
Pushes elem onto the queue, increasing capacity of queue if necessary.
GraphNodeType & reference
graph_iterator & operator=(const graph_iterator &other)
Assignment.
void deactivate_graph(graph &g)
virtual task * execute()=0
Should be overridden by derived classes.
graph_task_priority_queue_t & my_priority_queue
tbb::task * graph_root_task
bool operator==(const graph_iterator &other) const
Equality.
graph_iterator & operator++()
Pre-increment.
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
std::list< tbb::task * > task_list_type
Used to form groups of tasks.
internal::graph_task_priority_queue_t my_priority_queue
void prepare_task_arena(bool reinit=false)
void wait_for_all()
Wait until graph is idle and decrement_wait_count calls equals increment_wait_count calls...
tbb::task_arena * my_task_arena
task * execute() __TBB_override
Should be overridden by derived classes.
task_list_type my_reset_task_list
void execute_in_graph_arena(graph &g, F &f)
Executes custom functor inside graph arena.
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
Base class for user-defined tasks.
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
graph_iterator()
Default constructor.
void make_critical(task &t)
A functor that spawns a task.
bool is_cancelled()
return status of graph execution
A lock that occupies a single byte.
run_and_put_task(Receiver &r, Body &body)
Base class for types that should not be copied or assigned.
bool is_graph_active(graph &g)
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
GraphContainerType * my_graph
graph_task(node_priority_t node_priority=no_priority)
Base class for tasks generated by graph nodes.
tbb::concurrent_priority_queue< graph_task *, graph_task_comparator > graph_task_priority_queue_t
priority_task_selector(graph_task_priority_queue_t &priority_queue)
Tag class used to indicate the "attaching" constructor.