Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
Loading...
Searching...
No Matches
pipeline.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2005-2020 Intel Corporation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef __TBB_pipeline_H
18#define __TBB_pipeline_H
19
20#define __TBB_pipeline_H_include_area
22
23#include "atomic.h"
24#include "task.h"
25#include "tbb_allocator.h"
26#include <cstddef>
27
28#if __TBB_CPP11_TYPE_PROPERTIES_PRESENT
29#include <type_traits>
30#endif
31
32namespace tbb {
33
34class pipeline;
35class filter;
36
38namespace internal {
39
40// The argument for PIPELINE_VERSION should be an integer between 2 and 9
41#define __TBB_PIPELINE_VERSION(x) ((unsigned char)(x-2)<<1)
42
43typedef unsigned long Token;
44typedef long tokendiff_t;
45class stage_task;
46class input_buffer;
49
50} // namespace internal
51
52namespace interface6 {
53 template<typename T, typename U> class filter_t;
54
55 namespace internal {
56 class pipeline_proxy;
57 }
58}
59
61
63
65private:
67 static filter* not_in_pipeline() { return reinterpret_cast<filter*>(intptr_t(-1)); }
68protected:
70 static const unsigned char filter_is_serial = 0x1;
71
73
75 static const unsigned char filter_is_out_of_order = 0x1<<4;
76
78 static const unsigned char filter_is_bound = 0x1<<5;
79
81 static const unsigned char filter_may_emit_null = 0x1<<6;
82
84 static const unsigned char exact_exception_propagation =
85#if TBB_USE_CAPTURED_EXCEPTION
86 0x0;
87#else
88 0x1<<7;
89#endif /* TBB_USE_CAPTURED_EXCEPTION */
90
91 static const unsigned char current_version = __TBB_PIPELINE_VERSION(5);
92 static const unsigned char version_mask = 0x7<<1; // bits 1-3 are for version
93public:
94 enum mode {
103 };
104protected:
105 explicit filter( bool is_serial_ ) :
107 my_input_buffer(NULL),
108 my_filter_mode(static_cast<unsigned char>((is_serial_ ? serial : parallel) | exact_exception_propagation)),
110 my_pipeline(NULL),
111 next_segment(NULL)
112 {}
113
114 explicit filter( mode filter_mode ) :
116 my_input_buffer(NULL),
117 my_filter_mode(static_cast<unsigned char>(filter_mode | exact_exception_propagation)),
119 my_pipeline(NULL),
120 next_segment(NULL)
121 {}
122
123 // signal end-of-input for concrete_filters
125
126public:
128 bool is_serial() const {
129 return bool( my_filter_mode & filter_is_serial );
130 }
131
133 bool is_ordered() const {
135 }
136
138 bool is_bound() const {
140 }
141
145 }
146
148
149 virtual void* operator()( void* item ) = 0;
150
152
154
155#if __TBB_TASK_GROUP_CONTEXT
157
159 virtual void finalize( void* /*item*/ ) {}
160#endif
161
162private:
165
167 // (pipeline has not yet reached end_of_input or this filter has not yet
168 // seen the last token produced by input_filter)
169 bool has_more_work();
170
172
174
177 friend class pipeline;
179
181 const unsigned char my_filter_mode;
182
185
188
190
192};
193
195
197public:
199 // item was processed
201 // item is currently not available
203 // there are no more items to process
205 };
206protected:
207 explicit thread_bound_filter(mode filter_mode):
208 filter(static_cast<mode>(filter_mode | filter::filter_is_bound))
209 {
210 __TBB_ASSERT(filter_mode & filter::filter_is_serial, "thread-bound filters must be serial");
211 }
212public:
214
220
222
227
228private:
230 result_type internal_process_item(bool is_blocking);
231};
232
234
235class __TBB_DEPRECATED_MSG("tbb::pipeline is deprecated, use tbb::parallel_pipeline") pipeline {
236public:
238 __TBB_EXPORTED_METHOD pipeline();
239
242 virtual __TBB_EXPORTED_METHOD ~pipeline();
243
245 void __TBB_EXPORTED_METHOD add_filter( filter& filter_ );
246
248 void __TBB_EXPORTED_METHOD run( size_t max_number_of_live_tokens );
249
250#if __TBB_TASK_GROUP_CONTEXT
252 void __TBB_EXPORTED_METHOD run( size_t max_number_of_live_tokens, tbb::task_group_context& context );
253#endif
254
256 void __TBB_EXPORTED_METHOD clear();
257
258private:
259 friend class internal::stage_task;
260 friend class internal::pipeline_root_task;
261 friend class filter;
262 friend class thread_bound_filter;
263 friend class internal::pipeline_cleaner;
265
267 filter* filter_list;
268
270 filter* filter_end;
271
273 task* end_counter;
274
276 atomic<internal::Token> input_tokens;
277
279 atomic<internal::Token> token_counter;
280
282 bool end_of_input;
283
285 bool has_thread_bound_filters;
286
288 void remove_filter( filter& filter_ );
289
291 void __TBB_EXPORTED_METHOD inject_token( task& self );
292
293#if __TBB_TASK_GROUP_CONTEXT
295 void clear_filters();
296#endif
297};
298
299//------------------------------------------------------------------------
300// Support for lambda-friendly parallel_pipeline interface
301//------------------------------------------------------------------------
302
303namespace flow {
304namespace interface11 {
305 template<typename Output> class input_node;
306}
307}
308
309namespace interface6 {
310
311namespace internal {
312 template<typename T, typename U, typename Body> class concrete_filter;
313}
314
319 template<typename T, typename U, typename Body> friend class internal::concrete_filter;
320 template<typename Output> friend class flow::interface11::input_node;
321public:
322 void stop() { is_pipeline_stopped = true; }
323};
324
326namespace internal {
327
328// Emulate std::is_trivially_copyable (false positives not allowed, false negatives suboptimal but safe).
329#if __TBB_CPP11_TYPE_PROPERTIES_PRESENT
330template<typename T> struct tbb_trivially_copyable { enum { value = std::is_trivially_copyable<T>::value }; };
331#else
332template<typename T> struct tbb_trivially_copyable { enum { value = false }; };
333template<typename T> struct tbb_trivially_copyable < T* > { enum { value = true }; };
334template<> struct tbb_trivially_copyable < bool > { enum { value = true }; };
335template<> struct tbb_trivially_copyable < char > { enum { value = true }; };
336template<> struct tbb_trivially_copyable < signed char > { enum { value = true }; };
337template<> struct tbb_trivially_copyable <unsigned char > { enum { value = true }; };
338template<> struct tbb_trivially_copyable < short > { enum { value = true }; };
339template<> struct tbb_trivially_copyable <unsigned short > { enum { value = true }; };
340template<> struct tbb_trivially_copyable < int > { enum { value = true }; };
341template<> struct tbb_trivially_copyable <unsigned int > { enum { value = true }; };
342template<> struct tbb_trivially_copyable < long > { enum { value = true }; };
343template<> struct tbb_trivially_copyable <unsigned long > { enum { value = true }; };
344template<> struct tbb_trivially_copyable < long long> { enum { value = true }; };
345template<> struct tbb_trivially_copyable <unsigned long long> { enum { value = true }; };
346template<> struct tbb_trivially_copyable < float > { enum { value = true }; };
347template<> struct tbb_trivially_copyable < double > { enum { value = true }; };
348template<> struct tbb_trivially_copyable < long double > { enum { value = true }; };
349#if !_MSC_VER || defined(_NATIVE_WCHAR_T_DEFINED)
350template<> struct tbb_trivially_copyable < wchar_t > { enum { value = true }; };
351#endif /* _MSC_VER||!defined(_NATIVE_WCHAR_T_DEFINED) */
352#endif // tbb_trivially_copyable
353
354template<typename T>
356 enum { value = sizeof(T) > sizeof(void *) || !tbb_trivially_copyable<T>::value };
357};
358
359// A helper class to customize how a type is passed between filters.
360// Usage: token_helper<T, use_allocator<T>::value>
361template<typename T, bool Allocate> class token_helper;
362
363// using tbb_allocator
364template<typename T>
365class token_helper<T, true> {
366public:
368 typedef T* pointer;
369 typedef T value_type;
370#if __TBB_CPP11_RVALUE_REF_PRESENT
372#else
373 static pointer create_token(const value_type & source)
374#endif
375 {
376 pointer output_t = allocator().allocate(1);
377 return new (output_t) T(tbb::internal::move(source));
378 }
379 static value_type & token(pointer & t) { return *t; }
380 static void * cast_to_void_ptr(pointer ref) { return (void *) ref; }
381 static pointer cast_from_void_ptr(void * ref) { return (pointer)ref; }
382 static void destroy_token(pointer token) {
383 allocator().destroy(token);
384 allocator().deallocate(token,1);
385 }
386};
387
388// pointer specialization
389template<typename T>
390class token_helper<T*, false> {
391public:
392 typedef T* pointer;
393 typedef T* value_type;
394 static pointer create_token(const value_type & source) { return source; }
395 static value_type & token(pointer & t) { return t; }
396 static void * cast_to_void_ptr(pointer ref) { return (void *)ref; }
397 static pointer cast_from_void_ptr(void * ref) { return (pointer)ref; }
398 static void destroy_token( pointer /*token*/) {}
399};
400
401// converting type to and from void*, passing objects directly
402template<typename T>
403class token_helper<T, false> {
404 typedef union {
407 } type_to_void_ptr_map;
408public:
409 typedef T pointer; // not really a pointer in this case.
410 typedef T value_type;
411 static pointer create_token(const value_type & source) { return source; }
412 static value_type & token(pointer & t) { return t; }
413 static void * cast_to_void_ptr(pointer ref) {
414 type_to_void_ptr_map mymap;
415 mymap.void_overlay = NULL;
416 mymap.actual_value = ref;
417 return mymap.void_overlay;
418 }
419 static pointer cast_from_void_ptr(void * ref) {
420 type_to_void_ptr_map mymap;
421 mymap.void_overlay = ref;
422 return mymap.actual_value;
423 }
424 static void destroy_token( pointer /*token*/) {}
425};
426
427// intermediate
428template<typename T, typename U, typename Body>
430 const Body& my_body;
432 typedef typename t_helper::pointer t_pointer;
434 typedef typename u_helper::pointer u_pointer;
435
436 void* operator()(void* input) __TBB_override {
437 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
438 u_pointer output_u = u_helper::create_token(my_body(tbb::internal::move(t_helper::token(temp_input))));
439 t_helper::destroy_token(temp_input);
440 return u_helper::cast_to_void_ptr(output_u);
441 }
442
443 void finalize(void * input) __TBB_override {
444 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
445 t_helper::destroy_token(temp_input);
446 }
447
448public:
449 concrete_filter(tbb::filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
450};
451
452// input
453template<typename U, typename Body>
454class concrete_filter<void,U,Body>: public filter {
455 const Body& my_body;
457 typedef typename u_helper::pointer u_pointer;
458
460 flow_control control;
461 u_pointer output_u = u_helper::create_token(my_body(control));
462 if(control.is_pipeline_stopped) {
463 u_helper::destroy_token(output_u);
465 return NULL;
466 }
467 return u_helper::cast_to_void_ptr(output_u);
468 }
469
470public:
471 concrete_filter(tbb::filter::mode filter_mode, const Body& body) :
472 filter(static_cast<tbb::filter::mode>(filter_mode | filter_may_emit_null)),
473 my_body(body)
474 {}
475};
476
477// output
478template<typename T, typename Body>
479class concrete_filter<T,void,Body>: public filter {
480 const Body& my_body;
482 typedef typename t_helper::pointer t_pointer;
483
484 void* operator()(void* input) __TBB_override {
485 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
486 my_body(tbb::internal::move(t_helper::token(temp_input)));
487 t_helper::destroy_token(temp_input);
488 return NULL;
489 }
490 void finalize(void* input) __TBB_override {
491 t_pointer temp_input = t_helper::cast_from_void_ptr(input);
492 t_helper::destroy_token(temp_input);
493 }
494
495public:
496 concrete_filter(tbb::filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
497};
498
499template<typename Body>
500class concrete_filter<void,void,Body>: public filter {
501 const Body& my_body;
502
504 flow_control control;
505 my_body(control);
506 void* output = control.is_pipeline_stopped ? NULL : (void*)(intptr_t)-1;
507 return output;
508 }
509public:
510 concrete_filter(filter::mode filter_mode, const Body& body) : filter(filter_mode), my_body(body) {}
511};
512
514
516 tbb::pipeline my_pipe;
517public:
518 pipeline_proxy( const filter_t<void,void>& filter_chain );
520 while( filter* f = my_pipe.filter_list )
521 delete f; // filter destructor removes it from the pipeline
522 }
523 tbb::pipeline* operator->() { return &my_pipe; }
524};
525
527
530 tbb::atomic<intptr_t> ref_count;
531protected:
533 ref_count = 0;
534#ifdef __TBB_TEST_FILTER_NODE_COUNT
535 ++(__TBB_TEST_FILTER_NODE_COUNT);
536#endif
537 }
538public:
540 virtual void add_to( pipeline& ) = 0;
542 void add_ref() { ++ref_count; }
544 void remove_ref() {
545 __TBB_ASSERT(ref_count>0,"ref_count underflow");
546 if( --ref_count==0 )
547 delete this;
548 }
549 virtual ~filter_node() {
550#ifdef __TBB_TEST_FILTER_NODE_COUNT
551 --(__TBB_TEST_FILTER_NODE_COUNT);
552#endif
553 }
554};
555
557template<typename T, typename U, typename Body>
560 const Body body;
561 void add_to( pipeline& p ) __TBB_override {
563 p.add_filter( *f );
564 }
565public:
566 filter_node_leaf( tbb::filter::mode m, const Body& b ) : mode(m), body(b) {}
567};
568
571 friend class filter_node; // to suppress GCC 3.2 warnings
577 }
578 void add_to( pipeline& p ) __TBB_override {
579 left.add_to(p);
580 right.add_to(p);
581 }
582public:
584 left.add_ref();
585 right.add_ref();
586 }
587};
588
589} // namespace internal
591
593template<typename T, typename U, typename Body>
596}
597
598template<typename T, typename V, typename U>
600 __TBB_ASSERT(left.root,"cannot use default-constructed filter_t as left argument of '&'");
601 __TBB_ASSERT(right.root,"cannot use default-constructed filter_t as right argument of '&'");
602 return new internal::filter_node_join(*left.root,*right.root);
603}
604
606template<typename T, typename U>
607class filter_t {
610 filter_t( filter_node* root_ ) : root(root_) {
611 root->add_ref();
612 }
614 template<typename T_, typename U_, typename Body>
615 friend filter_t<T_,U_> make_filter(tbb::filter::mode, const Body& );
616 template<typename T_, typename V_, typename U_>
618public:
619 // TODO: add move-constructors, move-assignment, etc. where C++11 is available.
620 filter_t() : root(NULL) {}
621 filter_t( const filter_t<T,U>& rhs ) : root(rhs.root) {
622 if( root ) root->add_ref();
623 }
624 template<typename Body>
625 filter_t( tbb::filter::mode mode, const Body& body ) :
626 root( new internal::filter_node_leaf<T,U,Body>(mode, body) ) {
627 root->add_ref();
628 }
629
630 void operator=( const filter_t<T,U>& rhs ) {
631 // Order of operations below carefully chosen so that reference counts remain correct
632 // in unlikely event that remove_ref throws exception.
633 filter_node* old = root;
634 root = rhs.root;
635 if( root ) root->add_ref();
636 if( old ) old->remove_ref();
637 }
639 if( root ) root->remove_ref();
640 }
641 void clear() {
642 // Like operator= with filter_t() on right side.
643 if( root ) {
644 filter_node* old = root;
645 root = NULL;
646 old->remove_ref();
647 }
648 }
649};
650
651inline internal::pipeline_proxy::pipeline_proxy( const filter_t<void,void>& filter_chain ) : my_pipe() {
652 __TBB_ASSERT( filter_chain.root, "cannot apply parallel_pipeline to default-constructed filter_t" );
653 filter_chain.root->add_to(my_pipe);
654}
655
656inline void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t<void,void>& filter_chain
658 , tbb::task_group_context& context
659#endif
660 ) {
661 internal::pipeline_proxy pipe(filter_chain);
662 // tbb::pipeline::run() is called via the proxy
663 pipe->run(max_number_of_live_tokens
665 , context
666#endif
667 );
668}
669
670#if __TBB_TASK_GROUP_CONTEXT
671inline void parallel_pipeline(size_t max_number_of_live_tokens, const filter_t<void,void>& filter_chain) {
673 parallel_pipeline(max_number_of_live_tokens, filter_chain, context);
674}
675#endif // __TBB_TASK_GROUP_CONTEXT
676
677} // interface6
678
679using interface6::flow_control;
680using interface6::filter_t;
683
684} // tbb
685
687#undef __TBB_pipeline_H_include_area
688
689#endif /* __TBB_pipeline_H */
#define __TBB_PIPELINE_VERSION(x)
Definition pipeline.h:41
#define __TBB_DEPRECATED_MSG(msg)
Definition tbb_config.h:637
#define __TBB_TASK_GROUP_CONTEXT
Definition tbb_config.h:541
#define __TBB_EXPORTED_METHOD
Definition tbb_stddef.h:98
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition tbb_stddef.h:165
#define __TBB_override
Definition tbb_stddef.h:240
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
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
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 const char const char int ITT_FORMAT __itt_group_sync p
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
The graph class.
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
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
filter_t< T, U > operator&(const filter_t< T, V > &left, const filter_t< V, U > &right)
Definition pipeline.h:599
long tokendiff_t
Definition pipeline.h:44
unsigned long Token
Definition pipeline.h:43
An executable node that acts as a source, i.e. it has no predecessors.
Definition flow_graph.h:904
Class representing a chain of type-safe pipeline filters.
Definition pipeline.h:607
filter_t(const filter_t< T, U > &rhs)
Definition pipeline.h:621
friend filter_t< T_, U_ > operator&(const filter_t< T_, V_ > &, const filter_t< V_, U_ > &)
filter_t(filter_node *root_)
Definition pipeline.h:610
filter_t(tbb::filter::mode mode, const Body &body)
Definition pipeline.h:625
internal::filter_node filter_node
Definition pipeline.h:608
friend filter_t< T_, U_ > make_filter(tbb::filter::mode, const Body &)
Create a filter to participate in parallel_pipeline.
Definition pipeline.h:594
void operator=(const filter_t< T, U > &rhs)
Definition pipeline.h:630
A stage in a pipeline.
Definition pipeline.h:64
static const unsigned char filter_is_out_of_order
4th bit distinguishes ordered vs unordered filters.
Definition pipeline.h:75
static const unsigned char filter_is_bound
5th bit distinguishes thread-bound and regular filters.
Definition pipeline.h:78
filter(mode filter_mode)
Definition pipeline.h:114
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.
Definition pipeline.h:133
internal::input_buffer * my_input_buffer
Buffer for incoming tokens, or NULL if not required.
Definition pipeline.h:173
static const unsigned char current_version
Definition pipeline.h:91
bool has_more_work()
has the filter not yet processed all the tokens it will ever see?
Definition pipeline.cpp:691
static const unsigned char filter_may_emit_null
6th bit marks input filters emitting small objects
Definition pipeline.h:81
friend class pipeline
Definition pipeline.h:177
virtual void finalize(void *)
Destroys item if pipeline was cancelled.
Definition pipeline.h:159
@ parallel
processes multiple items in parallel and in no particular order
Definition pipeline.h:96
@ serial_in_order
processes items one at a time; all such filters process items in the same order
Definition pipeline.h:98
@ serial_out_of_order
processes items one at a time and in no particular order
Definition pipeline.h:100
static filter * not_in_pipeline()
Value used to mark "not in pipeline".
Definition pipeline.h:67
static const unsigned char version_mask
Definition pipeline.h:92
filter * next_filter_in_pipeline
Pointer to next filter in the pipeline.
Definition pipeline.h:164
bool is_bound() const
True if filter is thread-bound.
Definition pipeline.h:138
static const unsigned char exact_exception_propagation
7th bit defines exception propagation mode expected by the application.
Definition pipeline.h:84
filter * next_segment
Pointer to the next "segment" of filters, or NULL if not required.
Definition pipeline.h:191
const unsigned char my_filter_mode
Storage for filter mode and dynamically checked implementation version.
Definition pipeline.h:181
filter(bool is_serial_)
Definition pipeline.h:105
static const unsigned char filter_is_serial
The lowest bit 0 is for parallel vs. serial.
Definition pipeline.h:70
bool object_may_be_null()
true if an input filter can emit null
Definition pipeline.h:143
filter * prev_filter_in_pipeline
Pointer to previous filter in the pipeline.
Definition pipeline.h:184
void __TBB_EXPORTED_METHOD set_end_of_input()
Definition pipeline.cpp:708
pipeline * my_pipeline
Pointer to the pipeline.
Definition pipeline.h:187
bool is_serial() const
True if filter is serial.
Definition pipeline.h:128
virtual __TBB_EXPORTED_METHOD ~filter()
Destroy filter.
Definition pipeline.cpp:697
A stage in a pipeline served by a user thread.
Definition pipeline.h:196
result_type __TBB_EXPORTED_METHOD try_process_item()
If a data item is available, invoke operator() on that item.
Definition pipeline.cpp:723
thread_bound_filter(mode filter_mode)
Definition pipeline.h:207
result_type internal_process_item(bool is_blocking)
Internal routine for item processing.
Definition pipeline.cpp:727
result_type __TBB_EXPORTED_METHOD process_item()
Wait until a data item becomes available, and invoke operator() on that item.
Definition pipeline.cpp:719
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
Definition pipeline.h:443
token_helper< T, use_allocator< T >::value > t_helper
Definition pipeline.h:431
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition pipeline.h:449
token_helper< U, use_allocator< U >::value > u_helper
Definition pipeline.h:433
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition pipeline.h:436
input_filter control to signal end-of-input for parallel_pipeline
Definition pipeline.h:316
static value_type & token(pointer &t)
Definition pipeline.h:379
static pointer create_token(value_type &&source)
Definition pipeline.h:371
static pointer create_token(const value_type &source)
Definition pipeline.h:394
static pointer create_token(const value_type &source)
Definition pipeline.h:411
static value_type & token(pointer &t)
Definition pipeline.h:412
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition pipeline.h:471
token_helper< U, use_allocator< U >::value > u_helper
Definition pipeline.h:456
void * operator()(void *) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition pipeline.h:459
void * operator()(void *input) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition pipeline.h:484
void finalize(void *input) __TBB_override
Destroys item if pipeline was cancelled.
Definition pipeline.h:490
token_helper< T, use_allocator< T >::value > t_helper
Definition pipeline.h:481
concrete_filter(tbb::filter::mode filter_mode, const Body &body)
Definition pipeline.h:496
concrete_filter(filter::mode filter_mode, const Body &body)
Definition pipeline.h:510
void * operator()(void *) __TBB_override
Operate on an item from the input stream, and return item for output stream.
Definition pipeline.h:503
The class that represents an object of the pipeline for parallel_pipeline().
Definition pipeline.h:515
pipeline_proxy(const filter_t< void, void > &filter_chain)
Definition pipeline.h:651
Abstract base class that represents a node in a parse tree underlying a filter_t.
Definition pipeline.h:528
void add_ref()
Increment reference count.
Definition pipeline.h:542
tbb::atomic< intptr_t > ref_count
Definition pipeline.h:530
void remove_ref()
Decrement reference count and delete if it becomes zero.
Definition pipeline.h:544
virtual void add_to(pipeline &)=0
Add concrete_filter to pipeline.
Node in parse tree representing result of make_filter.
Definition pipeline.h:558
filter_node_leaf(tbb::filter::mode m, const Body &b)
Definition pipeline.h:566
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
Definition pipeline.h:561
Node in parse tree representing join of two filters.
Definition pipeline.h:570
filter_node_join(filter_node &x, filter_node &y)
Definition pipeline.h:583
void add_to(pipeline &p) __TBB_override
Add concrete_filter to pipeline.
Definition pipeline.h:578
Used to form groups of tasks.
Definition task.h:358
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
void destroy(pointer p)
Destroy value at location pointed to by p.
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
Base class for types that should not be copied or assigned.
Definition tbb_stddef.h:330
A buffer of input items for a filter.
Definition pipeline.cpp:48

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.