21 #ifndef __TBB_pipeline_H 22 #define __TBB_pipeline_H 29 #if __TBB_CPP11_TYPE_PROPERTIES_PRESENT || __TBB_TR1_TYPE_PROPERTIES_IN_STD_PRESENT 30 #include <type_traits> 42 #define __TBB_PIPELINE_VERSION(x) ((unsigned char)(x-2)<<1) 53 namespace interface6 {
54 template<
typename T,
typename U>
class filter_t;
86 #if TBB_USE_CAPTURED_EXCEPTION 156 #if __TBB_TASK_GROUP_CONTEXT 251 #if __TBB_TASK_GROUP_CONTEXT 294 #if __TBB_TASK_GROUP_CONTEXT 304 namespace interface6 {
325 #if __TBB_CPP11_TYPE_PROPERTIES_PRESENT 327 #elif __TBB_TR1_TYPE_PROPERTIES_IN_STD_PRESENT 341 #endif // Obtaining type properties 356 return new (output_t) T(source);
386 } type_to_void_ptr_map;
394 type_to_void_ptr_map mymap;
395 mymap.void_overlay = NULL;
396 mymap.actual_value = ref;
397 return mymap.void_overlay;
400 type_to_void_ptr_map mymap;
401 mymap.void_overlay = ref;
402 return mymap.actual_value;
407 template<
typename T,
typename U,
typename Body>
416 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
417 u_pointer output_u = u_helper::create_token(
my_body(t_helper::token(temp_input)));
418 t_helper::destroy_token(temp_input);
419 return u_helper::cast_to_void_ptr(output_u);
423 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
424 t_helper::destroy_token(temp_input);
432 template<
typename U,
typename Body>
442 u_helper::destroy_token(output_u);
446 return u_helper::cast_to_void_ptr(output_u);
456 template<
typename T,
typename Body>
463 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
464 my_body(t_helper::token(temp_input));
465 t_helper::destroy_token(temp_input);
469 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
470 t_helper::destroy_token(temp_input);
477 template<
typename Body>
513 #ifdef __TBB_TEST_FILTER_NODE_COUNT 514 ++(__TBB_TEST_FILTER_NODE_COUNT);
529 #ifdef __TBB_TEST_FILTER_NODE_COUNT 530 --(__TBB_TEST_FILTER_NODE_COUNT);
536 template<
typename T,
typename U,
typename Body>
572 template<
typename T,
typename U,
typename Body>
574 return new internal::filter_node_leaf<T,U,Body>(
mode, body);
577 template<
typename T,
typename V,
typename U>
579 __TBB_ASSERT(left.
root,
"cannot use default-constructed filter_t as left argument of '&'");
580 __TBB_ASSERT(right.
root,
"cannot use default-constructed filter_t as right argument of '&'");
581 return new internal::filter_node_join(*left.
root,*right.
root);
585 template<
typename T,
typename U>
593 template<
typename T_,
typename U_,
typename Body>
595 template<
typename T_,
typename V_,
typename U_>
603 template<
typename Body>
605 root( new internal::filter_node_leaf<T,U,Body>(
mode, body) ) {
615 if( old ) old->remove_ref();
631 __TBB_ASSERT( filter_chain.
root,
"cannot apply parallel_pipeline to default-constructed filter_t" );
640 internal::pipeline_proxy pipe(filter_chain);
642 pipe->run(max_number_of_live_tokens
649 #if __TBB_TASK_GROUP_CONTEXT 654 #endif // __TBB_TASK_GROUP_CONTEXT 658 using interface6::flow_control;
659 using interface6::filter_t;
static void * cast_to_void_ptr(pointer ref)
__TBB_EXPORTED_METHOD pipeline()
Construct empty pipeline.
bool has_more_work()
has the filter not yet processed all the tokens it will ever see?
static void * cast_to_void_ptr(pointer ref)
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
A processing pipeline that applies filters to items.
bool is_serial() const
True if filter is serial.
friend filter_t< T_, U_ > make_filter(tbb::filter::mode, const Body &)
Create a filter to participate in parallel_pipeline.
task * end_counter
task who's reference count is used to determine when all stages are done.
Node in parse tree representing result of make_filter.
virtual __TBB_EXPORTED_METHOD ~filter()
Destroy filter.
tbb::atomic< intptr_t > ref_count
Class representing a chain of type-safe pipeline filters.
void add_ref()
Increment reference count.
static const unsigned char filter_may_emit_null
6th bit marks input filters emitting small objects
result_type __TBB_EXPORTED_METHOD try_process_item()
If a data item is available, invoke operator() on that item.
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
virtual __TBB_EXPORTED_METHOD ~pipeline()
A buffer of input items for a filter.
static pointer cast_from_void_ptr(void *ref)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
filter_t< T, U > make_filter(tbb::filter::mode mode, const Body &body)
Create a filter to participate in parallel_pipeline.
friend filter_t< T_, U_ > operator&(const filter_t< T_, V_ > &, const filter_t< V_, U_ > &)
static filter * not_in_pipeline()
Value used to mark "not in pipeline".
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
const unsigned char my_filter_mode
Storage for filter mode and dynamically checked implementation version.
input_filter control to signal end-of-input for parallel_pipeline
Used to form groups of tasks.
static const unsigned char filter_is_bound
5th bit distinguishes thread-bound and regular filters.
void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t< void, void > &filter_chain, tbb::task_group_context &context)
A stage in a pipeline served by a user thread.
static const unsigned char filter_is_out_of_order
4th bit distinguishes ordered vs unordered filters.
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Abstract base class that represents a node in a parse tree underlying a filter_t.
filter * next_filter_in_pipeline
Pointer to next filter in the pipeline.
filter_t(tbb::filter::mode mode, const Body &body)
token_helper< T, is_large_object< T >::value > t_helper
static pointer cast_from_void_ptr(void *ref)
friend class internal::pipeline_root_task
filter_node_join(filter_node &x, filter_node &y)
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
token_helper< T, is_large_object< T >::value > t_helper
filter * next_segment
Pointer to the next "segment" of filters, or NULL if not required.
Base class for types that should not be copied or assigned.
void __TBB_EXPORTED_METHOD run(size_t max_number_of_live_tokens)
Run the pipeline to completion.
tbb::tbb_allocator< T > allocator
internal::filter_node filter_node
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
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
Base class for user-defined tasks.
static void * cast_to_void_ptr(pointer ref)
static void destroy_token(pointer)
const tbb::filter::mode mode
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
filter * filter_list
Pointer to first filter in the pipeline.
processes items one at a time; all such filters process items in the same order
concrete_filter(filter::mode filter_mode, const Body &body)
void remove_filter(filter &filter_)
Remove filter from pipeline.
static value_type & token(pointer &t)
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
friend class internal::concrete_filter
void clear_filters()
Does clean up if pipeline is cancelled or exception occurred.
static void destroy_token(pointer token)
friend class internal::stage_task
void const char const char int ITT_FORMAT __itt_group_sync p
filter * filter_end
Pointer to location where address of next filter to be added should be stored.
bool has_thread_bound_filters
True if the pipeline contains a thread-bound filter; false otherwise.
virtual void * operator()(void *item)=0
Operate on an item from the input stream, and return item for output stream.
bool is_ordered() const
True if filter must receive stream in order.
static const unsigned char current_version
filter_t< T, U > operator&(const filter_t< T, V > &left, const filter_t< V, U > &right)
void __TBB_EXPORTED_METHOD add_filter(filter &filter_)
Add filter to end of pipeline.
static const unsigned char filter_is_serial
The lowest bit 0 is for parallel vs. serial.
filter_t(filter_node *root_)
virtual void add_to(pipeline &)=0
Add concrete_filter to pipeline.
static void destroy_token(pointer)
result_type internal_process_item(bool is_blocking)
Internal routine for item processing.
token_helper< U, is_large_object< U >::value > u_helper
#define __TBB_EXPORTED_METHOD
bool object_may_be_null()
true if an input filter can emit null
static pointer create_token(const value_type &source)
processes multiple items in parallel and in no particular order
filter * prev_filter_in_pipeline
Pointer to previous filter in the pipeline.
result_type __TBB_EXPORTED_METHOD process_item()
Wait until a data item becomes available, and invoke operator() on that item.
static value_type & token(pointer &t)
tbb::pipeline * operator->()
pipeline * my_pipeline
Pointer to the pipeline.
static pointer cast_from_void_ptr(void *ref)
static const unsigned char exact_exception_propagation
7th bit defines exception propagation mode expected by the application.
void destroy(pointer p)
Destroy value at location pointed to by p.
pipeline_proxy(const filter_t< void, void > &filter_chain)
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
void remove_ref()
Decrement reference count and delete if it becomes zero.
#define __TBB_PIPELINE_VERSION(x)
atomic< internal::Token > input_tokens
Number of idle tokens waiting for input stage.
filter_node_leaf(tbb::filter::mode m, const Body &b)
static pointer create_token(const value_type &source)
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
friend class internal::pipeline_cleaner
void operator=(const filter_t< T, U > &rhs)
friend class internal::stage_task
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
u_helper::pointer u_pointer
void * operator()(void *) __TBB_override
void __TBB_EXPORTED_METHOD inject_token(task &self)
Not used, but retained to satisfy old export files.
token_helper< U, is_large_object< U >::value > u_helper
virtual void finalize(void *)
Destroys item if pipeline was cancelled.
friend class internal::pipeline_proxy
atomic< internal::Token > token_counter
Global counter of tokens.
t_helper::pointer t_pointer
Node in parse tree representing join of two filters.
The class that represents an object of the pipeline for parallel_pipeline().
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_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
bool is_bound() const
True if filter is thread-bound.
void __TBB_EXPORTED_METHOD clear()
Remove all filters from the pipeline.
thread_bound_filter(mode filter_mode)
processes items one at a time and in no particular order
static value_type & token(pointer &t)
void __TBB_EXPORTED_METHOD set_end_of_input()
t_helper::pointer t_pointer
filter_t(const filter_t< T, U > &rhs)
void * operator()(void *) __TBB_override
Operate on an item from the input stream, and return item for output stream.
static const unsigned char version_mask
internal::input_buffer * my_input_buffer
Buffer for incoming tokens, or NULL if not required.
u_helper::pointer u_pointer
static pointer create_token(const value_type &source)
#define __TBB_TASK_GROUP_CONTEXT
friend class internal::pipeline_root_task
bool end_of_input
False until fetch_input returns NULL.