pipeline.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_pipeline_H
#define __TBB_pipeline_H
#define __TBB_pipeline_H_include_area
#include "internal/_warning_suppress_enable_notice.h"
#include "atomic.h"
#include "task.h"
#include "tbb_allocator.h"
#include <cstddef>
#if __TBB_CPP11_TYPE_PROPERTIES_PRESENT
#include <type_traits>
#endif
namespace tbb {
class pipeline;
class filter;
namespace internal {
// The argument for PIPELINE_VERSION should be an integer between 2 and 9
#define __TBB_PIPELINE_VERSION(x) ((unsigned char)(x-2)<<1)
typedef unsigned long Token;
typedef long tokendiff_t;
class stage_task;
class input_buffer;
class pipeline_root_task;
class pipeline_cleaner;
} // namespace internal
namespace interface6 {
template<typename T, typename U> class filter_t;
namespace internal {
class pipeline_proxy;
}
}
class filter: internal::no_copy {
private:
static filter* not_in_pipeline() { return reinterpret_cast<filter*>(intptr_t(-1)); }
protected:
static const unsigned char filter_is_serial = 0x1;
static const unsigned char filter_is_out_of_order = 0x1<<4;
static const unsigned char filter_is_bound = 0x1<<5;
static const unsigned char filter_may_emit_null = 0x1<<6;
static const unsigned char exact_exception_propagation =
#if TBB_USE_CAPTURED_EXCEPTION
0x0;
#else
0x1<<7;
#endif /* TBB_USE_CAPTURED_EXCEPTION */
static const unsigned char current_version = __TBB_PIPELINE_VERSION(5);
static const unsigned char version_mask = 0x7<<1; // bits 1-3 are for version
public:
enum mode {
parallel = current_version | filter_is_out_of_order,
serial_in_order = current_version | filter_is_serial,
serial_out_of_order = current_version | filter_is_serial | filter_is_out_of_order,
serial = serial_in_order
};
protected:
explicit filter( bool is_serial_ ) :
next_filter_in_pipeline(not_in_pipeline()),
my_input_buffer(NULL),
my_filter_mode(static_cast<unsigned char>((is_serial_ ? serial : parallel) | exact_exception_propagation)),
prev_filter_in_pipeline(not_in_pipeline()),
my_pipeline(NULL),
next_segment(NULL)
{}
explicit filter( mode filter_mode ) :
next_filter_in_pipeline(not_in_pipeline()),
my_input_buffer(NULL),
my_filter_mode(static_cast<unsigned char>(filter_mode | exact_exception_propagation)),
prev_filter_in_pipeline(not_in_pipeline()),
my_pipeline(NULL),
next_segment(NULL)
{}
// signal end-of-input for concrete_filters
void __TBB_EXPORTED_METHOD set_end_of_input();
public:
bool is_serial() const {
return bool( my_filter_mode & filter_is_serial );
}
bool is_ordered() const {
return (my_filter_mode & (filter_is_out_of_order|filter_is_serial))==filter_is_serial;
}
bool is_bound() const {
return ( my_filter_mode & filter_is_bound )==filter_is_bound;
}
bool object_may_be_null() {
return ( my_filter_mode & filter_may_emit_null ) == filter_may_emit_null;
}
virtual void* operator()( void* item ) = 0;
virtual __TBB_EXPORTED_METHOD ~filter();
#if __TBB_TASK_GROUP_CONTEXT
virtual void finalize( void* /*item*/ ) {}
#endif
private:
filter* next_filter_in_pipeline;
// (pipeline has not yet reached end_of_input or this filter has not yet
// seen the last token produced by input_filter)
bool has_more_work();
internal::input_buffer* my_input_buffer;
friend class internal::stage_task;
friend class internal::pipeline_root_task;
friend class pipeline;
friend class thread_bound_filter;
const unsigned char my_filter_mode;
filter* prev_filter_in_pipeline;
pipeline* my_pipeline;
filter* next_segment;
};
class thread_bound_filter: public filter {
public:
enum result_type {
// item was processed
success,
// item is currently not available
item_not_available,
// there are no more items to process
end_of_stream
};
protected:
explicit thread_bound_filter(mode filter_mode):
filter(static_cast<mode>(filter_mode | filter::filter_is_bound))
{
__TBB_ASSERT(filter_mode & filter::filter_is_serial, "thread-bound filters must be serial");
}
public:
result_type __TBB_EXPORTED_METHOD try_process_item();
result_type __TBB_EXPORTED_METHOD process_item();
private:
result_type internal_process_item(bool is_blocking);
};
class __TBB_DEPRECATED_MSG("tbb::pipeline is deprecated, use tbb::parallel_pipeline") pipeline {
public:
__TBB_EXPORTED_METHOD pipeline();
virtual __TBB_EXPORTED_METHOD ~pipeline();
void __TBB_EXPORTED_METHOD add_filter( filter& filter_ );
void __TBB_EXPORTED_METHOD run( size_t max_number_of_live_tokens );
#if __TBB_TASK_GROUP_CONTEXT
void __TBB_EXPORTED_METHOD run( size_t max_number_of_live_tokens, tbb::task_group_context& context );
#endif
void __TBB_EXPORTED_METHOD clear();
private:
friend class internal::stage_task;
friend class internal::pipeline_root_task;
friend class filter;
friend class thread_bound_filter;
friend class internal::pipeline_cleaner;
friend class tbb::interface6::internal::pipeline_proxy;
filter* filter_list;
filter* filter_end;
task* end_counter;
atomic<internal::Token> input_tokens;
atomic<internal::Token> token_counter;
bool end_of_input;
bool has_thread_bound_filters;
void remove_filter( filter& filter_ );
void __TBB_EXPORTED_METHOD inject_token( task& self );
#if __TBB_TASK_GROUP_CONTEXT
void clear_filters();
#endif
};
//------------------------------------------------------------------------
// Support for lambda-friendly parallel_pipeline interface
//------------------------------------------------------------------------
namespace flow {
namespace interface11 {
template<typename Output> class input_node;
}
}
namespace interface6 {
namespace internal {
template<typename T, typename U, typename Body> class concrete_filter;
}
class flow_control {
bool is_pipeline_stopped;
flow_control() { is_pipeline_stopped = false; }
template<typename T, typename U, typename Body> friend class internal::concrete_filter;
template<typename Output> friend class flow::interface11::input_node;
public:
void stop() { is_pipeline_stopped = true; }
};
namespace internal {
// Emulate std::is_trivially_copyable (false positives not allowed, false negatives suboptimal but safe).
#if __TBB_CPP11_TYPE_PROPERTIES_PRESENT
template<typename T> struct tbb_trivially_copyable { enum { value = std::is_trivially_copyable<T>::value }; };
#else
template<typename T> struct tbb_trivially_copyable { enum { value = false }; };
template<typename T> struct tbb_trivially_copyable < T* > { enum { value = true }; };
template<> struct tbb_trivially_copyable < bool > { enum { value = true }; };
template<> struct tbb_trivially_copyable < char > { enum { value = true }; };
template<> struct tbb_trivially_copyable < signed char > { enum { value = true }; };
template<> struct tbb_trivially_copyable <unsigned char > { enum { value = true }; };
template<> struct tbb_trivially_copyable < short > { enum { value = true }; };
template<> struct tbb_trivially_copyable <unsigned short > { enum { value = true }; };
template<> struct tbb_trivially_copyable < int > { enum { value = true }; };
template<> struct tbb_trivially_copyable <unsigned int > { enum { value = true }; };
template<> struct tbb_trivially_copyable < long > { enum { value = true }; };
template<> struct tbb_trivially_copyable <unsigned long > { enum { value = true }; };
template<> struct tbb_trivially_copyable < long long> { enum { value = true }; };
template<> struct tbb_trivially_copyable <unsigned long long> { enum { value = true }; };
template<> struct tbb_trivially_copyable < float > { enum { value = true }; };
template<> struct tbb_trivially_copyable < double > { enum { value = true }; };
template<> struct tbb_trivially_copyable < long double > { enum { value = true }; };
#if !_MSC_VER || defined(_NATIVE_WCHAR_T_DEFINED)
template<> struct tbb_trivially_copyable < wchar_t > { enum { value = true }; };
#endif /* _MSC_VER||!defined(_NATIVE_WCHAR_T_DEFINED) */
#endif // tbb_trivially_copyable
template<typename T>
struct use_allocator {
enum { value = sizeof(T) > sizeof(void *) || !tbb_trivially_copyable<T>::value };
};
// A helper class to customize how a type is passed between filters.
// Usage: token_helper<T, use_allocator<T>::value>
template<typename T, bool Allocate> class token_helper;
// using tbb_allocator
template<typename T>
class token_helper<T, true> {
public:
typedef typename tbb::tbb_allocator<T> allocator;
typedef T* pointer;
typedef T value_type;
#if __TBB_CPP11_RVALUE_REF_PRESENT
static pointer create_token(value_type && source)
#else
static pointer create_token(const value_type & source)
#endif
{
pointer output_t = allocator().allocate(1);
return new (output_t) T(tbb::internal::move(source));
}
static value_type & token(pointer & t) { return *t; }
static void * cast_to_void_ptr(pointer ref) { return (void *) ref; }
static pointer cast_from_void_ptr(void * ref) { return (pointer)ref; }
static void destroy_token(pointer token) {
allocator().destroy(token);
allocator().deallocate(token,1);
}
};
// pointer specialization
template<typename T>
class token_helper<T*, false> {
public:
typedef T* pointer;
typedef T* value_type;
static pointer create_token(const value_type & source) { return source; }
static value_type & token(pointer & t) { return t; }
static void * cast_to_void_ptr(pointer ref) { return (void *)ref; }
static pointer cast_from_void_ptr(void * ref) { return (pointer)ref; }
static void destroy_token( pointer /*token*/) {}
};
// converting type to and from void*, passing objects directly
template<typename T>
class token_helper<T, false> {
typedef union {
T actual_value;
void * void_overlay;
} type_to_void_ptr_map;
public:
typedef T pointer; // not really a pointer in this case.
typedef T value_type;
static pointer create_token(const value_type & source) { return source; }
static value_type & token(pointer & t) { return t; }
static void * cast_to_void_ptr(pointer ref) {
type_to_void_ptr_map mymap;
mymap.void_overlay = NULL;
mymap.actual_value = ref;
return mymap.void_overlay;
}
static pointer cast_from_void_ptr(void * ref) {
type_to_void_ptr_map mymap;
mymap.void_overlay = ref;
return mymap.actual_value;
}
static void destroy_token( pointer /*token*/) {}
};
// intermediate
template<typename T, typename U, typename Body>
class concrete_filter: public tbb::filter {
const Body& my_body;
typedef token_helper<T,use_allocator<T>::value> t_helper;
typedef typename t_helper::pointer t_pointer;
typedef token_helper<U,use_allocator<U>::value> u_helper;
typedef typename u_helper::pointer u_pointer;
void* operator()(void* input) __TBB_override {
t_pointer temp_input = t_helper::cast_from_void_ptr(input);
u_pointer output_u = u_helper::create_token(my_body(tbb::internal::move(t_helper::token(temp_input))));
t_helper::destroy_token(temp_input);
return u_helper::cast_to_void_ptr(output_u);
}
void finalize(void * input) __TBB_override {
t_pointer temp_input = t_helper::cast_from_void_ptr(input);
t_helper::destroy_token(temp_input);
}
public:
concrete_filter(tbb::filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
};
// input
template<typename U, typename Body>
class concrete_filter<void,U,Body>: public filter {
const Body& my_body;
typedef token_helper<U, use_allocator<U>::value> u_helper;
typedef typename u_helper::pointer u_pointer;
void* operator()(void*) __TBB_override {
flow_control control;
u_pointer output_u = u_helper::create_token(my_body(control));
if(control.is_pipeline_stopped) {
u_helper::destroy_token(output_u);
set_end_of_input();
return NULL;
}
return u_helper::cast_to_void_ptr(output_u);
}
public:
concrete_filter(tbb::filter::mode filter_mode, const Body& body) :
filter(static_cast<tbb::filter::mode>(filter_mode | filter_may_emit_null)),
my_body(body)
{}
};
// output
template<typename T, typename Body>
class concrete_filter<T,void,Body>: public filter {
const Body& my_body;
typedef token_helper<T, use_allocator<T>::value> t_helper;
typedef typename t_helper::pointer t_pointer;
void* operator()(void* input) __TBB_override {
t_pointer temp_input = t_helper::cast_from_void_ptr(input);
my_body(tbb::internal::move(t_helper::token(temp_input)));
t_helper::destroy_token(temp_input);
return NULL;
}
void finalize(void* input) __TBB_override {
t_pointer temp_input = t_helper::cast_from_void_ptr(input);
t_helper::destroy_token(temp_input);
}
public:
concrete_filter(tbb::filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
};
template<typename Body>
class concrete_filter<void,void,Body>: public filter {
const Body& my_body;
void* operator()(void*) __TBB_override {
flow_control control;
my_body(control);
void* output = control.is_pipeline_stopped ? NULL : (void*)(intptr_t)-1;
return output;
}
public:
concrete_filter(filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
};
class pipeline_proxy {
tbb::pipeline my_pipe;
public:
pipeline_proxy( const filter_t<void,void>& filter_chain );
~pipeline_proxy() {
while( filter* f = my_pipe.filter_list )
delete f; // filter destructor removes it from the pipeline
}
tbb::pipeline* operator->() { return &my_pipe; }
};
class filter_node: tbb::internal::no_copy {
tbb::atomic<intptr_t> ref_count;
protected:
filter_node() {
ref_count = 0;
#ifdef __TBB_TEST_FILTER_NODE_COUNT
++(__TBB_TEST_FILTER_NODE_COUNT);
#endif
}
public:
virtual void add_to( pipeline& ) = 0;
void add_ref() { ++ref_count; }
void remove_ref() {
__TBB_ASSERT(ref_count>0,"ref_count underflow");
if( --ref_count==0 )
delete this;
}
virtual ~filter_node() {
#ifdef __TBB_TEST_FILTER_NODE_COUNT
--(__TBB_TEST_FILTER_NODE_COUNT);
#endif
}
};
template<typename T, typename U, typename Body>
class filter_node_leaf: public filter_node {
const tbb::filter::mode mode;
const Body body;
void add_to( pipeline& p ) __TBB_override {
concrete_filter<T,U,Body>* f = new concrete_filter<T,U,Body>(mode,body);
p.add_filter( *f );
}
public:
filter_node_leaf( tbb::filter::mode m, const Body& b ) : mode(m), body(b) {}
};
class filter_node_join: public filter_node {
friend class filter_node; // to suppress GCC 3.2 warnings
filter_node& left;
filter_node& right;
~filter_node_join() {
left.remove_ref();
right.remove_ref();
}
void add_to( pipeline& p ) __TBB_override {
left.add_to(p);
right.add_to(p);
}
public:
filter_node_join( filter_node& x, filter_node& y ) : left(x), right(y) {
left.add_ref();
right.add_ref();
}
};
} // namespace internal
template<typename T, typename U, typename Body>
filter_t<T,U> make_filter(tbb::filter::mode mode, const Body& body) {
return new internal::filter_node_leaf<T,U,Body>(mode, body);
}
template<typename T, typename V, typename U>
filter_t<T,U> operator& (const filter_t<T,V>& left, const filter_t<V,U>& right) {
__TBB_ASSERT(left.root,"cannot use default-constructed filter_t as left argument of '&'");
__TBB_ASSERT(right.root,"cannot use default-constructed filter_t as right argument of '&'");
return new internal::filter_node_join(*left.root,*right.root);
}
template<typename T, typename U>
class filter_t {
typedef internal::filter_node filter_node;
filter_node* root;
filter_t( filter_node* root_ ) : root(root_) {
root->add_ref();
}
friend class internal::pipeline_proxy;
template<typename T_, typename U_, typename Body>
friend filter_t<T_,U_> make_filter(tbb::filter::mode, const Body& );
template<typename T_, typename V_, typename U_>
friend filter_t<T_,U_> operator& (const filter_t<T_,V_>& , const filter_t<V_,U_>& );
public:
// TODO: add move-constructors, move-assignment, etc. where C++11 is available.
filter_t() : root(NULL) {}
filter_t( const filter_t<T,U>& rhs ) : root(rhs.root) {
if( root ) root->add_ref();
}
template<typename Body>
filter_t( tbb::filter::mode mode, const Body& body ) :
root( new internal::filter_node_leaf<T,U,Body>(mode, body) ) {
root->add_ref();
}
void operator=( const filter_t<T,U>& rhs ) {
// Order of operations below carefully chosen so that reference counts remain correct
// in unlikely event that remove_ref throws exception.
filter_node* old = root;
root = rhs.root;
if( root ) root->add_ref();
if( old ) old->remove_ref();
}
~filter_t() {
if( root ) root->remove_ref();
}
void clear() {
// Like operator= with filter_t() on right side.
if( root ) {
filter_node* old = root;
root = NULL;
old->remove_ref();
}
}
};
inline internal::pipeline_proxy::pipeline_proxy( const filter_t<void,void>& filter_chain ) : my_pipe() {
__TBB_ASSERT( filter_chain.root, "cannot apply parallel_pipeline to default-constructed filter_t" );
filter_chain.root->add_to(my_pipe);
}
inline void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t<void,void>& filter_chain
#if __TBB_TASK_GROUP_CONTEXT
, tbb::task_group_context& context
#endif
) {
internal::pipeline_proxy pipe(filter_chain);
// tbb::pipeline::run() is called via the proxy
pipe->run(max_number_of_live_tokens
#if __TBB_TASK_GROUP_CONTEXT
, context
#endif
);
}
#if __TBB_TASK_GROUP_CONTEXT
inline void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t<void,void>& filter_chain) {
tbb::task_group_context context;
parallel_pipeline(max_number_of_live_tokens, filter_chain, context);
}
#endif // __TBB_TASK_GROUP_CONTEXT
} // interface6
using interface6::flow_control;
using interface6::filter_t;
using interface6::make_filter;
using interface6::parallel_pipeline;
} // tbb
#include "internal/_warning_suppress_disable_notice.h"
#undef __TBB_pipeline_H_include_area
#endif /* __TBB_pipeline_H */
atomic.h
_warning_suppress_disable_notice.h
_warning_suppress_enable_notice.h
__TBB_PIPELINE_VERSION
#define __TBB_PIPELINE_VERSION(x)
Definition: pipeline.h:41
task.h
tbb_allocator.h
__TBB_TASK_GROUP_CONTEXT
#define __TBB_TASK_GROUP_CONTEXT
Definition: tbb_config.h:542
__TBB_EXPORTED_METHOD
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:98
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
__TBB_override
#define __TBB_override
Definition: tbb_stddef.h:240
task
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 * task
Definition: ittnotify_static.h:119
void
void
Definition: ittnotify_static.h:91
value
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 ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
Definition: ittnotify_static.h:192
mode
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 mode
Definition: ittnotify_static.h:109
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
int
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 ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
Definition: ittnotify_static.h:217
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::__TBB_DEPRECATED_MSG
class __TBB_DEPRECATED_MSG("tbb::tbb_hash is deprecated, use std::hash") tbb_hash
Definition: _tbb_hash_compare_impl.h:86
tbb::move
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
tbb::interface6::parallel_pipeline
void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t< void, void > &filter_chain, tbb::task_group_context &context)
Definition: pipeline.h:656
tbb::interface6::operator&
filter_t< T, U > operator&(const filter_t< T, V > &left, const filter_t< V, U > &right)
Definition: pipeline.h:599
tbb::interface6::make_filter
filter_t< T, U > make_filter(tbb::filter::mode mode, const Body &body)
Create a filter to participate in parallel_pipeline.
Definition: pipeline.h:594
tbb::interface6::parallel_pipeline
void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t< void, void > &filter_chain)
Definition: pipeline.h:671
tbb::internal::tokendiff_t
long tokendiff_t
Definition: pipeline.h:44
tbb::internal::Token
unsigned long Token
Definition: pipeline.h:43
internal
Definition: _flow_graph_async_msg_impl.h:24
tbb::flow::interface11::input_node
An executable node that acts as a source, i.e. it has no predecessors.
Definition: flow_graph.h:904
tbb::interface6::filter_t
Class representing a chain of type-safe pipeline filters.
Definition: pipeline.h:607
tbb::interface6::filter_t::filter_t
filter_t()
Definition: pipeline.h:620
tbb::interface6::filter_t::make_filter
friend filter_t< T_, U_ > make_filter(tbb::filter::mode, const Body &)
Create a filter to participate in parallel_pipeline.
Definition: pipeline.h:594
tbb::interface6::filter_t::filter_t
filter_t(const filter_t< T, U > &rhs)
Definition: pipeline.h:621
tbb::interface6::filter_t::clear
void clear()
Definition: pipeline.h:641
tbb::interface6::filter_t::filter_t
filter_t(filter_node *root_)
Definition: pipeline.h:610
tbb::interface6::filter_t::filter_t
filter_t(tbb::filter::mode mode, const Body &body)
Definition: pipeline.h:625
tbb::interface6::filter_t::root
filter_node * root
Definition: pipeline.h:609
tbb::interface6::filter_t::filter_node
internal::filter_node filter_node
Definition: pipeline.h:608
tbb::interface6::filter_t::operator&
friend filter_t< T_, U_ > operator&(const filter_t< T_, V_ > &, const filter_t< V_, U_ > &)
tbb::interface6::filter_t::operator=
void operator=(const filter_t< T, U > &rhs)
Definition: pipeline.h:630
tbb::interface6::filter_t::~filter_t
~filter_t()
Definition: pipeline.h:638
tbb::filter
A stage in a pipeline.
Definition: pipeline.h:64
tbb::filter::operator()
virtual void * operator()(void *item)=0
Operate on an item from the input stream, and return item for output stream.
tbb::filter::filter_is_out_of_order
static const unsigned char filter_is_out_of_order
4th bit distinguishes ordered vs unordered filters.
Definition: pipeline.h:75
tbb::filter::filter_is_bound
static const unsigned char filter_is_bound
5th bit distinguishes thread-bound and regular filters.
Definition: pipeline.h:78
tbb::filter::filter
filter(mode filter_mode)
Definition: pipeline.h:114
tbb::filter::is_ordered
bool is_ordered() const
True if filter must receive stream in order.
Definition: pipeline.h:133
tbb::filter::my_input_buffer
internal::input_buffer * my_input_buffer
Buffer for incoming tokens, or NULL if not required.
Definition: pipeline.h:173
tbb::filter::current_version
static const unsigned char current_version
Definition: pipeline.h:91
tbb::filter::has_more_work
bool has_more_work()
has the filter not yet processed all the tokens it will ever see?
Definition: pipeline.cpp:691
tbb::filter::filter_may_emit_null
static const unsigned char filter_may_emit_null
6th bit marks input filters emitting small objects
Definition: pipeline.h:81
tbb::filter::pipeline
friend class pipeline
Definition: pipeline.h:177
tbb::filter::finalize
virtual void finalize(void *)
Destroys item if pipeline was cancelled.
Definition: pipeline.h:159
tbb::filter::mode
mode
Definition: pipeline.h:94
tbb::filter::parallel
@ parallel
processes multiple items in parallel and in no particular order
Definition: pipeline.h:96
tbb::filter::serial
@ serial
Definition: pipeline.h:102
tbb::filter::serial_in_order
@ serial_in_order
processes items one at a time; all such filters process items in the same order
Definition: pipeline.h:98
tbb::filter::serial_out_of_order
@ serial_out_of_order
processes items one at a time and in no particular order
Definition: pipeline.h:100
tbb::filter::version_mask
static const unsigned char version_mask
Definition: pipeline.h:92
tbb::filter::next_filter_in_pipeline
filter * next_filter_in_pipeline
Pointer to next filter in the pipeline.
Definition: pipeline.h:164
tbb::filter::is_bound
bool is_bound() const
True if filter is thread-bound.
Definition: pipeline.h:138
tbb::filter::not_in_pipeline
static filter * not_in_pipeline()
Value used to mark "not in pipeline".
Definition: pipeline.h:67
tbb::filter::exact_exception_propagation
static const unsigned char exact_exception_propagation
7th bit defines exception propagation mode expected by the application.
Definition: pipeline.h:84
tbb::filter::next_segment
filter * next_segment
Pointer to the next "segment" of filters, or NULL if not required.
Definition: pipeline.h:191
tbb::filter::my_filter_mode
const unsigned char my_filter_mode
Storage for filter mode and dynamically checked implementation version.
Definition: pipeline.h:181
tbb::filter::filter
filter(bool is_serial_)
Definition: pipeline.h:105
tbb::filter::filter_is_serial
static const unsigned char filter_is_serial
The lowest bit 0 is for parallel vs. serial.
Definition: pipeline.h:70
tbb::filter::object_may_be_null
bool object_may_be_null()
true if an input filter can emit null
Definition: pipeline.h:143
tbb::filter::prev_filter_in_pipeline
filter * prev_filter_in_pipeline
Pointer to previous filter in the pipeline.
Definition: pipeline.h:184
tbb::filter::set_end_of_input
void __TBB_EXPORTED_METHOD set_end_of_input()
Definition: pipeline.cpp:708
tbb::filter::my_pipeline
pipeline * my_pipeline
Pointer to the pipeline.
Definition: pipeline.h:187
tbb::filter::is_serial
bool is_serial() const
True if filter is serial.
Definition: pipeline.h:128
tbb::filter::~filter
virtual __TBB_EXPORTED_METHOD ~filter()
Destroy filter.
Definition: pipeline.cpp:697
tbb::thread_bound_filter
A stage in a pipeline served by a user thread.
Definition: pipeline.h:196
tbb::thread_bound_filter::result_type
result_type
Definition: pipeline.h:198
tbb::thread_bound_filter::success
@ success
Definition: pipeline.h:200
tbb::thread_bound_filter::end_of_stream
@ end_of_stream
Definition: pipeline.h:204
tbb::thread_bound_filter::item_not_available
@ item_not_available
Definition: pipeline.h:202
tbb::thread_bound_filter::try_process_item
result_type __TBB_EXPORTED_METHOD try_process_item()
If a data item is available, invoke operator() on that item.
Definition: pipeline.cpp:723
tbb::thread_bound_filter::thread_bound_filter
thread_bound_filter(mode filter_mode)
Definition: pipeline.h:207
tbb::thread_bound_filter::internal_process_item
result_type internal_process_item(bool is_blocking)
Internal routine for item processing.
Definition: pipeline.cpp:727
tbb::thread_bound_filter::process_item
result_type __TBB_EXPORTED_METHOD process_item()
Wait until a data item becomes available, and invoke operator() on that item.
Definition: pipeline.cpp:719
tbb::interface6::internal::concrete_filter
Definition: pipeline.h:429
tbb::interface6::internal::concrete_filter::finalize
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
Definition: pipeline.h:443
tbb::interface6::internal::concrete_filter::my_body
const Body & my_body
Definition: pipeline.h:430
tbb::interface6::internal::concrete_filter::t_helper
token_helper< T, use_allocator< T >::value > t_helper
Definition: pipeline.h:431
tbb::interface6::internal::concrete_filter::concrete_filter
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition: pipeline.h:449
tbb::interface6::internal::concrete_filter::operator()
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition: pipeline.h:436
tbb::interface6::internal::concrete_filter::u_pointer
u_helper::pointer u_pointer
Definition: pipeline.h:434
tbb::interface6::internal::concrete_filter::u_helper
token_helper< U, use_allocator< U >::value > u_helper
Definition: pipeline.h:433
tbb::interface6::internal::concrete_filter::t_pointer
t_helper::pointer t_pointer
Definition: pipeline.h:432
tbb::interface6::flow_control
input_filter control to signal end-of-input for parallel_pipeline
Definition: pipeline.h:316
tbb::interface6::flow_control::stop
void stop()
Definition: pipeline.h:322
tbb::interface6::flow_control::flow_control
flow_control()
Definition: pipeline.h:318
tbb::interface6::flow_control::is_pipeline_stopped
bool is_pipeline_stopped
Definition: pipeline.h:317
tbb::interface6::internal::tbb_trivially_copyable
Definition: pipeline.h:332
tbb::interface6::internal::tbb_trivially_copyable::value
@ value
Definition: pipeline.h:332
tbb::interface6::internal::use_allocator
Definition: pipeline.h:355
tbb::interface6::internal::token_helper
Definition: pipeline.h:361
tbb::interface6::internal::token_helper< T, true >::token
static value_type & token(pointer &t)
Definition: pipeline.h:379
tbb::interface6::internal::token_helper< T, true >::cast_to_void_ptr
static void * cast_to_void_ptr(pointer ref)
Definition: pipeline.h:380
tbb::interface6::internal::token_helper< T, true >::allocator
tbb::tbb_allocator< T > allocator
Definition: pipeline.h:367
tbb::interface6::internal::token_helper< T, true >::pointer
T * pointer
Definition: pipeline.h:368
tbb::interface6::internal::token_helper< T, true >::destroy_token
static void destroy_token(pointer token)
Definition: pipeline.h:382
tbb::interface6::internal::token_helper< T, true >::cast_from_void_ptr
static pointer cast_from_void_ptr(void *ref)
Definition: pipeline.h:381
tbb::interface6::internal::token_helper< T, true >::create_token
static pointer create_token(value_type &&source)
Definition: pipeline.h:371
tbb::interface6::internal::token_helper< T, true >::value_type
T value_type
Definition: pipeline.h:369
tbb::interface6::internal::token_helper< T *, false >::cast_from_void_ptr
static pointer cast_from_void_ptr(void *ref)
Definition: pipeline.h:397
tbb::interface6::internal::token_helper< T *, false >::pointer
T * pointer
Definition: pipeline.h:392
tbb::interface6::internal::token_helper< T *, false >::destroy_token
static void destroy_token(pointer)
Definition: pipeline.h:398
tbb::interface6::internal::token_helper< T *, false >::cast_to_void_ptr
static void * cast_to_void_ptr(pointer ref)
Definition: pipeline.h:396
tbb::interface6::internal::token_helper< T *, false >::create_token
static pointer create_token(const value_type &source)
Definition: pipeline.h:394
tbb::interface6::internal::token_helper< T *, false >::value_type
T * value_type
Definition: pipeline.h:393
tbb::interface6::internal::token_helper< T *, false >::token
static value_type & token(pointer &t)
Definition: pipeline.h:395
tbb::interface6::internal::token_helper< T, false >::value_type
T value_type
Definition: pipeline.h:410
tbb::interface6::internal::token_helper< T, false >::create_token
static pointer create_token(const value_type &source)
Definition: pipeline.h:411
tbb::interface6::internal::token_helper< T, false >::token
static value_type & token(pointer &t)
Definition: pipeline.h:412
tbb::interface6::internal::token_helper< T, false >::pointer
T pointer
Definition: pipeline.h:409
tbb::interface6::internal::token_helper< T, false >::cast_to_void_ptr
static void * cast_to_void_ptr(pointer ref)
Definition: pipeline.h:413
tbb::interface6::internal::token_helper< T, false >::destroy_token
static void destroy_token(pointer)
Definition: pipeline.h:424
tbb::interface6::internal::token_helper< T, false >::cast_from_void_ptr
static pointer cast_from_void_ptr(void *ref)
Definition: pipeline.h:419
tbb::interface6::internal::token_helper< T, false >::type_to_void_ptr_map::actual_value
T actual_value
Definition: pipeline.h:405
tbb::interface6::internal::token_helper< T, false >::type_to_void_ptr_map::void_overlay
void * void_overlay
Definition: pipeline.h:406
tbb::interface6::internal::concrete_filter< void, U, Body >::operator()
void * operator()(void *) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition: pipeline.h:459
tbb::interface6::internal::concrete_filter< void, U, Body >::u_pointer
u_helper::pointer u_pointer
Definition: pipeline.h:457
tbb::interface6::internal::concrete_filter< void, U, Body >::concrete_filter
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition: pipeline.h:471
tbb::interface6::internal::concrete_filter< void, U, Body >::my_body
const Body & my_body
Definition: pipeline.h:455
tbb::interface6::internal::concrete_filter< void, U, Body >::u_helper
token_helper< U, use_allocator< U >::value > u_helper
Definition: pipeline.h:456
tbb::interface6::internal::concrete_filter< T, void, Body >::finalize
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
Definition: pipeline.h:490
tbb::interface6::internal::concrete_filter< T, void, Body >::t_helper
token_helper< T, use_allocator< T >::value > t_helper
Definition: pipeline.h:481
tbb::interface6::internal::concrete_filter< T, void, Body >::concrete_filter
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition: pipeline.h:496
tbb::interface6::internal::concrete_filter< T, void, Body >::t_pointer
t_helper::pointer t_pointer
Definition: pipeline.h:482
tbb::interface6::internal::concrete_filter< T, void, Body >::operator()
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition: pipeline.h:484
tbb::interface6::internal::concrete_filter< T, void, Body >::my_body
const Body & my_body
Definition: pipeline.h:480
tbb::interface6::internal::concrete_filter< void, void, Body >::concrete_filter
concrete_filter(filter::mode filter_mode, const Body &body)
Definition: pipeline.h:510
tbb::interface6::internal::concrete_filter< void, void, Body >::my_body
const Body & my_body
Definition: pipeline.h:501
tbb::interface6::internal::concrete_filter< void, void, Body >::operator()
void * operator()(void *) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition: pipeline.h:503
tbb::interface6::internal::pipeline_proxy
The class that represents an object of the pipeline for parallel_pipeline().
Definition: pipeline.h:515
tbb::interface6::internal::pipeline_proxy::~pipeline_proxy
~pipeline_proxy()
Definition: pipeline.h:519
tbb::interface6::internal::pipeline_proxy::operator->
tbb::pipeline * operator->()
Definition: pipeline.h:523
tbb::interface6::internal::pipeline_proxy::pipeline_proxy
pipeline_proxy(const filter_t< void, void > &filter_chain)
Definition: pipeline.h:651
tbb::interface6::internal::pipeline_proxy::my_pipe
tbb::pipeline my_pipe
Definition: pipeline.h:516
tbb::interface6::internal::filter_node
Abstract base class that represents a node in a parse tree underlying a filter_t.
Definition: pipeline.h:528
tbb::interface6::internal::filter_node::add_ref
void add_ref()
Increment reference count.
Definition: pipeline.h:542
tbb::interface6::internal::filter_node::ref_count
tbb::atomic< intptr_t > ref_count
Definition: pipeline.h:530
tbb::interface6::internal::filter_node::remove_ref
void remove_ref()
Decrement reference count and delete if it becomes zero.
Definition: pipeline.h:544
tbb::interface6::internal::filter_node::~filter_node
virtual ~filter_node()
Definition: pipeline.h:549
tbb::interface6::internal::filter_node::add_to
virtual void add_to(pipeline &)=0
Add concrete_filter to pipeline.
tbb::interface6::internal::filter_node::filter_node
filter_node()
Definition: pipeline.h:532
tbb::interface6::internal::filter_node_leaf
Node in parse tree representing result of make_filter.
Definition: pipeline.h:558
tbb::interface6::internal::filter_node_leaf::filter_node_leaf
filter_node_leaf(tbb::filter::mode m, const Body &b)
Definition: pipeline.h:566
tbb::interface6::internal::filter_node_leaf::add_to
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
Definition: pipeline.h:561
tbb::interface6::internal::filter_node_leaf::body
const Body body
Definition: pipeline.h:560
tbb::interface6::internal::filter_node_leaf::mode
const tbb::filter::mode mode
Definition: pipeline.h:559
tbb::interface6::internal::filter_node_join
Node in parse tree representing join of two filters.
Definition: pipeline.h:570
tbb::interface6::internal::filter_node_join::left
filter_node & left
Definition: pipeline.h:572
tbb::interface6::internal::filter_node_join::filter_node_join
filter_node_join(filter_node &x, filter_node &y)
Definition: pipeline.h:583
tbb::interface6::internal::filter_node_join::add_to
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
Definition: pipeline.h:578
tbb::interface6::internal::filter_node_join::right
filter_node & right
Definition: pipeline.h:573
tbb::interface6::internal::filter_node_join::~filter_node_join
~filter_node_join()
Definition: pipeline.h:574
tbb::task_group_context
Used to form groups of tasks.
Definition: task.h:358
tbb::tbb_allocator
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Definition: tbb_allocator.h:58
tbb::tbb_allocator::deallocate
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
Definition: tbb_allocator.h:90
tbb::tbb_allocator::destroy
void destroy(pointer p)
Destroy value at location pointed to by p.
Definition: tbb_allocator.h:113
tbb::tbb_allocator::allocate
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
Definition: tbb_allocator.h:85
tbb::internal::no_copy
Base class for types that should not be copied or assigned.
Definition: tbb_stddef.h:330
tbb::internal::input_buffer
A buffer of input items for a filter.
Definition: pipeline.cpp:48
tbb::internal::stage_task
Definition: pipeline.cpp:249
tbb::internal::pipeline_root_task
Definition: pipeline.cpp:400
tbb::internal::pipeline_cleaner
Definition: pipeline.cpp:500

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.