_flow_graph_impl.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __TBB_flow_graph_impl_H
#define __TBB_flow_graph_impl_H
#include "../tbb_stddef.h"
#include "../task.h"
#include "../task_arena.h"
#include "../flow_graph_abstractions.h"
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
#include "../concurrent_priority_queue.h"
#endif
#include <list>
#if TBB_DEPRECATED_FLOW_ENQUEUE
#define FLOW_SPAWN(a) tbb::task::enqueue((a))
#else
#define FLOW_SPAWN(a) tbb::task::spawn((a))
#endif
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
#define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr ) expr
#define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority ) , priority
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1, priority
#else
#define __TBB_FLOW_GRAPH_PRIORITY_EXPR( expr )
#define __TBB_FLOW_GRAPH_PRIORITY_ARG0( priority )
#define __TBB_FLOW_GRAPH_PRIORITY_ARG1( arg1, priority ) arg1
#endif // __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
#if TBB_DEPRECATED_LIMITER_NODE_CONSTRUCTOR
#define __TBB_DEPRECATED_LIMITER_EXPR( expr ) expr
#define __TBB_DEPRECATED_LIMITER_ARG2( arg1, arg2 ) arg1, arg2
#define __TBB_DEPRECATED_LIMITER_ARG4( arg1, arg2, arg3, arg4 ) arg1, arg3, arg4
#else
#define __TBB_DEPRECATED_LIMITER_EXPR( expr )
#define __TBB_DEPRECATED_LIMITER_ARG2( arg1, arg2 ) arg1
#define __TBB_DEPRECATED_LIMITER_ARG4( arg1, arg2, arg3, arg4 ) arg1, arg2
#endif // TBB_DEPRECATED_LIMITER_NODE_CONSTRUCTOR
namespace tbb {
namespace flow {
namespace internal {
static tbb::task * const SUCCESSFULLY_ENQUEUED = (task *)-1;
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
typedef unsigned int node_priority_t;
static const node_priority_t no_priority = node_priority_t(0);
#endif
}
namespace interface10 {
class graph;
}
namespace interface11 {
using tbb::flow::internal::SUCCESSFULLY_ENQUEUED;
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
using tbb::flow::internal::node_priority_t;
using tbb::flow::internal::no_priority;
struct graph_task : public task {
graph_task( node_priority_t node_priority = no_priority ) : priority( node_priority ) {}
node_priority_t priority;
};
#else
typedef task graph_task;
#endif /* __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES */
class graph_node;
template <typename GraphContainerType, typename GraphNodeType>
class graph_iterator {
friend class tbb::flow::interface10::graph;
friend class graph_node;
public:
typedef size_t size_type;
typedef GraphNodeType value_type;
typedef GraphNodeType* pointer;
typedef GraphNodeType& reference;
typedef const GraphNodeType& const_reference;
typedef std::forward_iterator_tag iterator_category;
graph_iterator() : my_graph(NULL), current_node(NULL) {}
graph_iterator(const graph_iterator& other) :
my_graph(other.my_graph), current_node(other.current_node)
{}
graph_iterator& operator=(const graph_iterator& other) {
if (this != &other) {
my_graph = other.my_graph;
current_node = other.current_node;
}
return *this;
}
reference operator*() const;
pointer operator->() const;
bool operator==(const graph_iterator& other) const {
return ((my_graph == other.my_graph) && (current_node == other.current_node));
}
bool operator!=(const graph_iterator& other) const { return !(operator==(other)); }
graph_iterator& operator++() {
internal_forward();
return *this;
}
graph_iterator operator++(int) {
graph_iterator result = *this;
operator++();
return result;
}
private:
// the graph over which we are iterating
GraphContainerType *my_graph;
// pointer into my_graph's my_nodes list
pointer current_node;
graph_iterator(GraphContainerType *g, bool begin);
void internal_forward();
}; // class graph_iterator
// flags to modify the behavior of the graph reset(). Can be combined.
enum reset_flags {
rf_reset_protocol = 0,
rf_reset_bodies = 1 << 0, // delete the current node body, reset to a copy of the initial node body.
rf_clear_edges = 1 << 1 // delete edges
};
namespace internal {
void activate_graph(tbb::flow::interface10::graph& g);
void deactivate_graph(tbb::flow::interface10::graph& g);
bool is_graph_active(tbb::flow::interface10::graph& g);
tbb::task& prioritize_task(tbb::flow::interface10::graph& g, tbb::task& arena_task);
void spawn_in_graph_arena(tbb::flow::interface10::graph& g, tbb::task& arena_task);
void enqueue_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task& arena_task);
void add_task_to_graph_reset_list(tbb::flow::interface10::graph& g, tbb::task *tp);
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
struct graph_task_comparator {
bool operator()(const graph_task* left, const graph_task* right) {
return left->priority < right->priority;
}
};
typedef tbb::concurrent_priority_queue<graph_task*, graph_task_comparator> graph_task_priority_queue_t;
class priority_task_selector : public task {
public:
priority_task_selector(graph_task_priority_queue_t& priority_queue)
: my_priority_queue(priority_queue) {}
task* execute() __TBB_override {
graph_task* t = NULL;
bool result = my_priority_queue.try_pop(t);
__TBB_ASSERT_EX( result, "Number of critical tasks for scheduler and tasks"
" in graph's priority queue mismatched" );
__TBB_ASSERT( t && t != SUCCESSFULLY_ENQUEUED,
"Incorrect task submitted to graph priority queue" );
__TBB_ASSERT( t->priority != tbb::flow::internal::no_priority,
"Tasks from graph's priority queue must have priority" );
task* t_next = t->execute();
task::destroy(*t);
return t_next;
}
private:
graph_task_priority_queue_t& my_priority_queue;
};
#endif /* __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES */
}
} // namespace interfaceX
namespace interface10 {
class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
friend class tbb::flow::interface11::graph_node;
template< typename Body >
class run_task : public tbb::flow::interface11::graph_task {
public:
run_task(Body& body
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
, tbb::flow::interface11::node_priority_t node_priority = tbb::flow::interface11::no_priority
) : tbb::flow::interface11::graph_task(node_priority),
#else
) :
#endif
my_body(body) { }
tbb::task *execute() __TBB_override {
my_body();
return NULL;
}
private:
Body my_body;
};
template< typename Receiver, typename Body >
class run_and_put_task : public tbb::flow::interface11::graph_task {
public:
run_and_put_task(Receiver &r, Body& body) : my_receiver(r), my_body(body) {}
tbb::task *execute() __TBB_override {
tbb::task *res = my_receiver.try_put_task(my_body());
if (res == tbb::flow::interface11::SUCCESSFULLY_ENQUEUED) res = NULL;
return res;
}
private:
Receiver &my_receiver;
Body my_body;
};
typedef std::list<tbb::task *> task_list_type;
class wait_functor {
tbb::task* graph_root_task;
public:
wait_functor(tbb::task* t) : graph_root_task(t) {}
void operator()() const { graph_root_task->wait_for_all(); }
};
class spawn_functor : tbb::internal::no_assign {
tbb::task& spawn_task;
public:
spawn_functor(tbb::task& t) : spawn_task(t) {}
void operator()() const {
FLOW_SPAWN(spawn_task);
}
};
void prepare_task_arena(bool reinit = false) {
if (reinit) {
__TBB_ASSERT(my_task_arena, "task arena is NULL");
my_task_arena->terminate();
my_task_arena->initialize(tbb::task_arena::attach());
}
else {
__TBB_ASSERT(my_task_arena == NULL, "task arena is not NULL");
my_task_arena = new tbb::task_arena(tbb::task_arena::attach());
}
if (!my_task_arena->is_active()) // failed to attach
my_task_arena->initialize(); // create a new, default-initialized arena
__TBB_ASSERT(my_task_arena->is_active(), "task arena is not active");
}
public:
graph();
explicit graph(tbb::task_group_context& use_this_context);
~graph();
#if TBB_PREVIEW_FLOW_GRAPH_TRACE
void set_name(const char *name);
#endif
void increment_wait_count() {
reserve_wait();
}
void decrement_wait_count() {
release_wait();
}
void reserve_wait() __TBB_override;
void release_wait() __TBB_override;
template< typename Receiver, typename Body >
void run(Receiver &r, Body body) {
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
task* rtask = new (task::allocate_additional_child_of(*root_task()))
run_and_put_task< Receiver, Body >(r, body);
my_task_arena->execute(spawn_functor(*rtask));
}
}
template< typename Body >
void run(Body body) {
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
task* rtask = new (task::allocate_additional_child_of(*root_task())) run_task< Body >(body);
my_task_arena->execute(spawn_functor(*rtask));
}
}
void wait_for_all() {
cancelled = false;
caught_exception = false;
if (my_root_task) {
#if TBB_USE_EXCEPTIONS
try {
#endif
my_task_arena->execute(wait_functor(my_root_task));
#if __TBB_TASK_GROUP_CONTEXT
cancelled = my_context->is_group_execution_cancelled();
#endif
#if TBB_USE_EXCEPTIONS
}
catch (...) {
my_root_task->set_ref_count(1);
my_context->reset();
caught_exception = true;
cancelled = true;
throw;
}
#endif
#if __TBB_TASK_GROUP_CONTEXT
// TODO: the "if" condition below is just a work-around to support the concurrent wait
// mode. The cancellation and exception mechanisms are still broken in this mode.
// Consider using task group not to re-implement the same functionality.
if (!(my_context->traits() & tbb::task_group_context::concurrent_wait)) {
my_context->reset(); // consistent with behavior in catch()
#endif
my_root_task->set_ref_count(1);
#if __TBB_TASK_GROUP_CONTEXT
}
#endif
}
}
tbb::task * root_task() {
return my_root_task;
}
// ITERATORS
template<typename C, typename N>
friend class tbb::flow::interface11::graph_iterator;
// Graph iterator typedefs
typedef tbb::flow::interface11::graph_iterator<graph, tbb::flow::interface11::graph_node> iterator;
typedef tbb::flow::interface11::graph_iterator<const graph, const tbb::flow::interface11::graph_node> const_iterator;
// Graph iterator constructors
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
bool is_cancelled() { return cancelled; }
bool exception_thrown() { return caught_exception; }
// thread-unsafe state reset.
void reset(tbb::flow::interface11::reset_flags f = tbb::flow::interface11::rf_reset_protocol);
private:
tbb::task *my_root_task;
#if __TBB_TASK_GROUP_CONTEXT
tbb::task_group_context *my_context;
#endif
bool own_context;
bool cancelled;
bool caught_exception;
bool my_is_active;
task_list_type my_reset_task_list;
tbb::flow::interface11::graph_node *my_nodes, *my_nodes_last;
tbb::spin_mutex nodelist_mutex;
void register_node(tbb::flow::interface11::graph_node *n);
void remove_node(tbb::flow::interface11::graph_node *n);
tbb::task_arena* my_task_arena;
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
tbb::flow::interface11::internal::graph_task_priority_queue_t my_priority_queue;
#endif
friend void tbb::flow::interface11::internal::activate_graph(graph& g);
friend void tbb::flow::interface11::internal::deactivate_graph(graph& g);
friend bool tbb::flow::interface11::internal::is_graph_active(graph& g);
friend tbb::task& tbb::flow::interface11::internal::prioritize_task(graph& g, tbb::task& arena_task);
friend void tbb::flow::interface11::internal::spawn_in_graph_arena(graph& g, tbb::task& arena_task);
friend void tbb::flow::interface11::internal::enqueue_in_graph_arena(graph &g, tbb::task& arena_task);
friend void tbb::flow::interface11::internal::add_task_to_graph_reset_list(graph& g, tbb::task *tp);
friend class tbb::interface7::internal::task_arena_base;
}; // class graph
} // namespace interface10
namespace interface11 {
using tbb::flow::interface10::graph;
#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
namespace internal{
class get_graph_helper;
}
#endif
class graph_node : tbb::internal::no_copy {
friend class graph;
template<typename C, typename N>
friend class graph_iterator;
#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
friend class internal::get_graph_helper;
#endif
protected:
graph& my_graph;
graph_node *next, *prev;
public:
explicit graph_node(graph& g);
virtual ~graph_node();
#if TBB_PREVIEW_FLOW_GRAPH_TRACE
virtual void set_name(const char *name) = 0;
#endif
#if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
virtual void extract() = 0;
#endif
protected:
// performs the reset on an individual node.
virtual void reset_node(reset_flags f = rf_reset_protocol) = 0;
}; // class graph_node
namespace internal {
inline void activate_graph(graph& g) {
g.my_is_active = true;
}
inline void deactivate_graph(graph& g) {
g.my_is_active = false;
}
inline bool is_graph_active(graph& g) {
return g.my_is_active;
}
#if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
inline tbb::task& prioritize_task(graph& g, tbb::task& t) {
task* critical_task = &t;
// TODO: change flow graph's interfaces to work with graph_task type instead of tbb::task.
graph_task* gt = static_cast<graph_task*>(&t);
if( gt->priority != no_priority ) {
critical_task = new( gt->allocate_continuation() ) priority_task_selector(g.my_priority_queue);
tbb::internal::make_critical( *critical_task );
g.my_priority_queue.push(gt);
}
return *critical_task;
}
#else
inline tbb::task& prioritize_task(graph&, tbb::task& t) {
return t;
}
#endif /* __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES */
inline void spawn_in_graph_arena(graph& g, tbb::task& arena_task) {
if (is_graph_active(g)) {
graph::spawn_functor s_fn(prioritize_task(g, arena_task));
__TBB_ASSERT(g.my_task_arena && g.my_task_arena->is_active(), NULL);
g.my_task_arena->execute(s_fn);
}
}
inline void enqueue_in_graph_arena(graph &g, tbb::task& arena_task) {
if (is_graph_active(g)) {
__TBB_ASSERT( g.my_task_arena && g.my_task_arena->is_active(), "Is graph's arena initialized and active?" );
task::enqueue(prioritize_task(g, arena_task), *g.my_task_arena);
}
}
inline void add_task_to_graph_reset_list(graph& g, tbb::task *tp) {
g.my_reset_task_list.push_back(tp);
}
} // namespace internal
} // namespace interfaceX
} // namespace flow
} // namespace tbb
#endif // __TBB_flow_graph_impl_H
tbb::flow::interface11::graph_iterator::reference
GraphNodeType & reference
Definition: _flow_graph_impl.h:98
tbb::flow::interface11::graph_iterator::operator==
bool operator==(const graph_iterator &other) const
Equality.
Definition: _flow_graph_impl.h:126
tbb::flow::interface10::graph::begin
iterator begin()
start iterator
Definition: flow_graph.h:858
tbb::task::set_ref_count
void set_ref_count(int count)
Set reference count.
Definition: task.h:750
tbb::interface7::task_arena::is_active
bool is_active() const
Definition: task_arena.h:374
tbb::spin_mutex
A lock that occupies a single byte.
Definition: spin_mutex.h:39
tbb::interface7::internal::task_arena_base
Definition: task_arena.h:105
tbb::flow::interface10::graph::remove_node
void remove_node(tbb::flow::interface11::graph_node *n)
Definition: flow_graph.h:823
internal
Definition: _flow_graph_async_msg_impl.h:24
tbb::flow::interface11::internal::priority_task_selector
Definition: _flow_graph_impl.h:183
tbb::flow::interface11::internal::is_graph_active
bool is_graph_active(tbb::flow::interface10::graph &g)
Definition: _flow_graph_impl.h:494
tbb::flow::interface11::internal::spawn_in_graph_arena
void spawn_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
Definition: _flow_graph_impl.h:521
tbb::flow::interface11::graph_iterator::operator++
graph_iterator operator++(int)
Post-increment.
Definition: _flow_graph_impl.h:140
tbb::task::wait_for_all
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:808
tbb::flow::interface11::graph_node::graph_node
graph_node(graph &g)
Definition: flow_graph.h:880
tbb::flow::interface10::graph::~graph
~graph()
Destroys the graph.
Definition: flow_graph.h:790
tbb::flow::interface10::graph::iterator
tbb::flow::interface11::graph_iterator< graph, tbb::flow::interface11::graph_node > iterator
Definition: _flow_graph_impl.h:383
tbb::flow::interface11::graph_iterator::operator->
pointer operator->() const
Dereference.
Definition: flow_graph.h:753
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::flow::interface10::graph::wait_functor
Definition: _flow_graph_impl.h:248
tbb::flow::interface11::reset_flags
reset_flags
Definition: _flow_graph_impl.h:158
tbb::flow::interface11::internal::add_task_to_graph_reset_list
void add_task_to_graph_reset_list(tbb::flow::interface10::graph &g, tbb::task *tp)
Definition: _flow_graph_impl.h:537
tbb::internal::no_copy
Base class for types that should not be copied or assigned.
Definition: tbb_stddef.h:330
tbb::flow::interface10::graph::my_context
tbb::task_group_context * my_context
Definition: _flow_graph_impl.h:410
tbb::interface7::task_arena::initialize
void initialize()
Forces allocation of the resources for the task_arena as specified in constructor arguments.
Definition: task_arena.h:315
tbb::flow::interface10::graph::my_task_arena
tbb::task_arena * my_task_arena
Definition: _flow_graph_impl.h:424
tbb::flow::interface10::graph::spawn_functor::spawn_functor
spawn_functor(tbb::task &t)
Definition: _flow_graph_impl.h:259
tbb::flow::interface10::graph::run_task::execute
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
Definition: _flow_graph_impl.h:225
tbb::interface7::task_arena::terminate
void terminate()
Definition: task_arena.h:359
tbb::task_group_context::concurrent_wait
Definition: task.h:376
tbb::flow::interface11::internal::priority_task_selector::my_priority_queue
graph_task_priority_queue_t & my_priority_queue
Definition: _flow_graph_impl.h:201
tbb::flow::interface11::graph_node::next
graph_node * next
Definition: _flow_graph_impl.h:465
tbb::flow::interface11::graph_iterator::internal_forward
void internal_forward()
Definition: flow_graph.h:758
tbb::flow::interface10::graph::run_task
Definition: _flow_graph_impl.h:215
tbb::flow::interface11::graph_iterator::operator!=
bool operator!=(const graph_iterator &other) const
Inequality.
Definition: _flow_graph_impl.h:131
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::flow::interface11::internal::graph_task_comparator
Definition: _flow_graph_impl.h:175
tbb::flow::interface10::graph::wait_for_all
void wait_for_all()
Wait until graph is idle and decrement_wait_count calls equals increment_wait_count calls.
Definition: _flow_graph_impl.h:338
tbb::flow::interface11::graph_iterator::operator++
graph_iterator & operator++()
Pre-increment.
Definition: _flow_graph_impl.h:134
tbb::flow::interface11::graph_node::reset_node
virtual void reset_node(reset_flags f=rf_reset_protocol)=0
tbb::flow::interface10::graph::wait_functor::wait_functor
wait_functor(tbb::task *t)
Definition: _flow_graph_impl.h:251
tbb::task_group_context
Used to form groups of tasks.
Definition: task.h:347
tbb::flow::interface10::graph::my_nodes_last
tbb::flow::interface11::graph_node * my_nodes_last
Definition: _flow_graph_impl.h:418
tbb::flow::interface10::graph::prepare_task_arena
void prepare_task_arena(bool reinit=false)
Definition: _flow_graph_impl.h:265
begin
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
Definition: ittnotify_static.h:182
tbb::flow::interface11::graph_proxy
Pure virtual template classes that define interfaces for async communication.
Definition: flow_graph_abstractions.h:25
tbb::interface7::task_arena::execute
internal::return_type_or_void< F >::type execute(F &f)
Definition: task_arena.h:423
tbb::flow::interface11::graph_task
Base class for tasks generated by graph nodes.
Definition: _flow_graph_impl.h:80
tbb::flow::interface10::graph::exception_thrown
bool exception_thrown()
Definition: _flow_graph_impl.h:402
tbb::flow::interface10::graph::cend
const_iterator cend() const
end const iterator
Definition: flow_graph.h:868
tbb::flow::interface11::graph_iterator::operator*
reference operator*() const
Dereference.
Definition: flow_graph.h:747
tbb::flow::interface10::graph::nodelist_mutex
tbb::spin_mutex nodelist_mutex
Definition: _flow_graph_impl.h:420
tbb::flow::internal::SUCCESSFULLY_ENQUEUED
static tbb::task *const SUCCESSFULLY_ENQUEUED
Definition: _flow_graph_impl.h:61
tbb::flow::interface10::graph::end
iterator end()
end iterator
Definition: flow_graph.h:860
tbb::flow::interface10::graph::run_and_put_task::my_receiver
Receiver & my_receiver
Definition: _flow_graph_impl.h:243
tbb::interface7::task_arena::attach
Tag class used to indicate the "attaching" constructor.
Definition: task_arena.h:304
tbb::flow::interface11::graph_node::prev
graph_node * prev
Definition: _flow_graph_impl.h:465
tbb::flow::interface10::graph::run_task::my_body
Body my_body
Definition: _flow_graph_impl.h:230
tbb::flow::interface11::graph_node::my_graph
graph & my_graph
Definition: _flow_graph_impl.h:464
tbb::flow::interface10::graph::cancelled
bool cancelled
Definition: _flow_graph_impl.h:413
tbb::flow::interface11::graph_iterator::my_graph
GraphContainerType * my_graph
Definition: _flow_graph_impl.h:148
tbb::flow::interface11::graph_iterator::size_type
size_t size_type
Definition: _flow_graph_impl.h:95
tbb::flow::interface11::graph_node
The base of all graph nodes.
Definition: _flow_graph_impl.h:454
tbb::flow::interface10::graph::graph
graph()
Constructs a graph with isolated task_group_context.
Definition: flow_graph.h:766
tbb::flow::interface10::graph::task_list_type
std::list< tbb::task * > task_list_type
Definition: _flow_graph_impl.h:246
tbb::flow::interface10::graph::increment_wait_count
void increment_wait_count()
Definition: _flow_graph_impl.h:295
tbb::flow::interface11::internal::priority_task_selector::priority_task_selector
priority_task_selector(graph_task_priority_queue_t &priority_queue)
Definition: _flow_graph_impl.h:185
tbb::flow::interface11::graph_iterator::graph_iterator
graph_iterator()
Default constructor.
Definition: _flow_graph_impl.h:103
tbb::flow::interface10::graph::my_nodes
tbb::flow::interface11::graph_node * my_nodes
Definition: _flow_graph_impl.h:418
tbb::task_group_context::reset
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
tbb::flow::internal::no_priority
static const node_priority_t no_priority
Definition: _flow_graph_impl.h:64
tbb::flow::interface11::graph_iterator::current_node
pointer current_node
Definition: _flow_graph_impl.h:150
tbb::flow::interface11::internal::prioritize_task
tbb::task & prioritize_task(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Definition: _flow_graph_impl.h:499
tbb::flow::interface10::graph::run
void run(Body body)
Spawns a task that runs a function object.
Definition: _flow_graph_impl.h:329
tbb::flow::interface10::graph::run_and_put_task::run_and_put_task
run_and_put_task(Receiver &r, Body &body)
Definition: _flow_graph_impl.h:236
tbb::flow::interface11::graph_iterator::value_type
GraphNodeType value_type
Definition: _flow_graph_impl.h:96
tbb::flow::interface11::rf_reset_protocol
Definition: _flow_graph_impl.h:159
tbb::flow::interface11::graph_iterator::pointer
GraphNodeType * pointer
Definition: _flow_graph_impl.h:97
tbb::task::enqueue
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
Definition: task.h:825
tbb::task_group_context::is_group_execution_cancelled
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
tbb::flow::interface10::graph::my_reset_task_list
task_list_type my_reset_task_list
Definition: _flow_graph_impl.h:416
tbb::flow::interface11::graph_iterator::const_reference
const typedef GraphNodeType & const_reference
Definition: _flow_graph_impl.h:99
tbb::flow::internal::node_priority_t
unsigned int node_priority_t
Definition: _flow_graph_impl.h:63
tbb::flow::interface10::graph::run_and_put_task::my_body
Body my_body
Definition: _flow_graph_impl.h:244
tbb::flow::interface10::graph::spawn_functor::spawn_task
tbb::task & spawn_task
Definition: _flow_graph_impl.h:257
tbb::task::execute
virtual task * execute()=0
Should be overridden by derived classes.
__TBB_override
#define __TBB_override
Definition: tbb_stddef.h:240
tbb::flow::interface10::graph::run_task::run_task
run_task(Body &body, tbb::flow::interface11::node_priority_t node_priority=tbb::flow::interface11::no_priority)
Definition: _flow_graph_impl.h:217
FLOW_SPAWN
#define FLOW_SPAWN(a)
Definition: _flow_graph_impl.h:34
tbb::flow::interface11::graph_iterator::operator=
graph_iterator & operator=(const graph_iterator &other)
Assignment.
Definition: _flow_graph_impl.h:111
tbb::flow::interface10::graph::run_and_put_task
Definition: _flow_graph_impl.h:234
tbb::internal::no_assign
Base class for types that should not be assigned.
Definition: tbb_stddef.h:322
tbb::flow::interface10::graph::decrement_wait_count
void decrement_wait_count()
Definition: _flow_graph_impl.h:299
tbb::flow::interface10::graph::const_iterator
tbb::flow::interface11::graph_iterator< const graph, const tbb::flow::interface11::graph_node > const_iterator
Definition: _flow_graph_impl.h:384
tbb::flow::interface10::graph::reset
void reset(tbb::flow::interface11::reset_flags f=tbb::flow::interface11::rf_reset_protocol)
Definition: flow_graph.h:835
tbb::flow::interface11::internal::graph_task_priority_queue_t
tbb::concurrent_priority_queue< graph_task *, graph_task_comparator > graph_task_priority_queue_t
Definition: _flow_graph_impl.h:181
tbb::flow::interface11::rf_clear_edges
Definition: _flow_graph_impl.h:161
__TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
#define __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
Definition: tbb_config.h:858
tbb::flow::interface11::internal::priority_task_selector::execute
task * execute() __TBB_override
Should be overridden by derived classes.
Definition: _flow_graph_impl.h:187
tbb::interface5::concurrent_priority_queue
Concurrent priority queue.
Definition: concurrent_priority_queue.h:68
tbb::flow::interface10::graph
The graph class.
Definition: _flow_graph_impl.h:211
tbb::flow::interface10::graph::reserve_wait
void reserve_wait() __TBB_override
Used to register that an external entity may still interact with the graph.
Definition: flow_graph.h:798
tbb::flow::interface10::graph::run
void run(Receiver &r, Body body)
Spawns a task that runs a body and puts its output to a specific receiver.
Definition: _flow_graph_impl.h:317
tbb::flow::interface11::graph_node::~graph_node
virtual ~graph_node()
Definition: flow_graph.h:884
tbb::flow::interface10::graph::register_node
void register_node(tbb::flow::interface11::graph_node *n)
Definition: flow_graph.h:812
tbb::flow::interface11::graph_iterator
Definition: _flow_graph_impl.h:91
tbb::flow::interface11::internal::deactivate_graph
void deactivate_graph(tbb::flow::interface10::graph &g)
Definition: _flow_graph_impl.h:490
tbb::flow::interface10::graph::spawn_functor::operator()
void operator()() const
Definition: _flow_graph_impl.h:260
tbb::task
Base class for user-defined tasks.
Definition: task.h:604
name
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
Definition: ittnotify_static.h:93
tbb::flow::interface11::internal::activate_graph
void activate_graph(tbb::flow::interface10::graph &g)
Definition: _flow_graph_impl.h:486
tbb::flow::interface11::internal::graph_task_comparator::operator()
bool operator()(const graph_task *left, const graph_task *right)
Definition: _flow_graph_impl.h:176
tbb::task::allocate_continuation
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
Definition: task.h:665
tbb::flow::interface10::graph::my_is_active
bool my_is_active
Definition: _flow_graph_impl.h:415
tbb::flow::interface11::rf_reset_bodies
Definition: _flow_graph_impl.h:160
tbb::flow::interface11::internal::enqueue_in_graph_arena
void enqueue_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Enqueues a task inside graph arena.
Definition: _flow_graph_impl.h:530
tbb::interface5::concurrent_priority_queue::try_pop
bool try_pop(reference elem)
Gets a reference to and removes highest priority element.
Definition: concurrent_priority_queue.h:302
tbb::internal::make_critical
void make_critical(task &t)
Definition: task.h:1002
tbb::flow::interface10::graph::my_root_task
tbb::task * my_root_task
Definition: _flow_graph_impl.h:408
tbb::flow::interface10::graph::cbegin
const_iterator cbegin() const
start const iterator
Definition: flow_graph.h:866
tbb::flow::interface10::graph::wait_functor::graph_root_task
tbb::task * graph_root_task
Definition: _flow_graph_impl.h:249
tbb::interface7::task_arena
Definition: task_arena.h:228
tbb::task_group_context::traits
uintptr_t traits() const
Returns the context's trait.
Definition: task.h:567
tbb::flow::interface10::graph::root_task
tbb::task * root_task()
Returns the root task of the graph.
Definition: _flow_graph_impl.h:374
tbb::interface5::concurrent_priority_queue::push
void push(const_reference elem)
Pushes elem onto the queue, increasing capacity of queue if necessary.
Definition: concurrent_priority_queue.h:268
tbb::flow::interface10::graph::wait_functor::operator()
void operator()() const
Definition: _flow_graph_impl.h:252
tbb::flow::interface10::graph::is_cancelled
bool is_cancelled()
return status of graph execution
Definition: _flow_graph_impl.h:401
tbb::flow::interface10::graph::release_wait
void release_wait() __TBB_override
Deregisters an external entity that may have interacted with the graph.
Definition: flow_graph.h:805
tbb::flow::interface10::graph::own_context
bool own_context
Definition: _flow_graph_impl.h:412
tbb::flow::interface10::graph::my_priority_queue
tbb::flow::interface11::internal::graph_task_priority_queue_t my_priority_queue
Definition: _flow_graph_impl.h:427
tbb::flow::interface10::graph::caught_exception
bool caught_exception
Definition: _flow_graph_impl.h:414
__TBB_ASSERT_EX
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
Definition: tbb_stddef.h:167
tbb::flow::interface10::graph::run_and_put_task::execute
tbb::task * execute() __TBB_override
Should be overridden by derived classes.
Definition: _flow_graph_impl.h:237
tbb::flow::interface11::graph_task::graph_task
graph_task(node_priority_t node_priority=no_priority)
Definition: _flow_graph_impl.h:81
tbb::flow::interface11::graph_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: _flow_graph_impl.h:100
tbb::flow::interface10::graph::spawn_functor
A functor that spawns a task.
Definition: _flow_graph_impl.h:256
tbb::flow::interface11::graph_task::priority
node_priority_t priority
Definition: _flow_graph_impl.h:82
tbb::flow::interface11::graph_iterator::graph_iterator
graph_iterator(const graph_iterator &other)
Copy constructor.
Definition: _flow_graph_impl.h:106

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.