177 template<
typename StageTask>
192 spawner.spawn_stage_task(wakee);
195 #if __TBB_TASK_GROUP_CONTEXT 243 new_array[i].is_valid =
false;
245 for(
size_type i=0; i<old_size; ++i, ++t )
246 new_array[t&(
new_size-1)] = old_array[t&(old_size-1)];
286 #if __TBB_TASK_GROUP_CONTEXT 295 #endif // __TBB_TASK_GROUP_CONTEXT 322 goto process_another_stage;
373 goto process_another_stage;
383 if(ntokens_avail == 1) {
396 process_another_stage:
420 filter* first_suitable_filter = current_filter;
421 while( current_filter ) {
451 if( !current_filter ) {
456 current_filter = first_suitable_filter;
462 first_suitable_filter = first_suitable_filter->
next_segment;
463 current_filter = first_suitable_filter;
483 for(
filter* subfilter=
first->next_filter_in_pipeline;
485 subfilter=subfilter->next_filter_in_pipeline )
487 if( subfilter->prev_filter_in_pipeline->is_bound() && !subfilter->is_bound() ) {
490 head_of_previous_segment = subfilter;
497 #if _MSC_VER && !defined(__INTEL_COMPILER) 500 #pragma warning (disable: 4127) 511 #if __TBB_TASK_GROUP_CONTEXT 525 #if __TBB_TASK_GROUP_CONTEXT 529 if( internal::input_buffer* b = f->my_input_buffer )
540 has_thread_bound_filters(false)
553 if( internal::input_buffer* b = f->my_input_buffer ) {
561 f->my_pipeline = NULL;
564 f->next_segment = NULL;
589 *reinterpret_cast<filter**>(
filter_end) = &filter_;
591 *reinterpret_cast<filter**>(
filter_end) = NULL;
651 __TBB_ASSERT( max_number_of_live_tokens>0,
"pipeline::run must have at least one token" );
663 #if __TBB_TASK_GROUP_CONTEXT 674 f->my_input_buffer->sema_V();
681 #if __TBB_TASK_GROUP_CONTEXT 690 run(max_number_of_live_tokens, context);
693 #endif // __TBB_TASK_GROUP_CONTEXT 732 __TBB_ASSERT(
my_pipeline != NULL,
"It's not supposed that process_item is called for a filter that is not in a pipeline.");
733 internal::task_info info;
747 info.my_object = (*this)(info.my_object);
748 if( info.my_object ) {
753 info.my_token_ready =
true;
773 info.my_object = (*this)(info.my_object);
777 __TBB_ASSERT(
false,
"Couldn't put token after thread-bound buffer");
782 if( ntokens_avail == 1 ) {
__TBB_EXPORTED_METHOD pipeline()
Construct empty pipeline.
bool has_more_work()
has the filter not yet processed all the tokens it will ever see?
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
A processing pipeline that applies filters to items.
bool is_serial() const
True if filter is serial.
task * end_counter
task who's reference count is used to determine when all stages are done.
virtual __TBB_EXPORTED_METHOD ~filter()
Destroy filter.
pipeline_cleaner(pipeline &_pipeline)
Token low_token
Lowest token that can start executing.
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
result_type __TBB_EXPORTED_METHOD try_process_item()
If a data item is available, invoke operator() on that item.
bool is_valid
True if my_object is valid.
virtual __TBB_EXPORTED_METHOD ~pipeline()
A buffer of input items for a filter.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
static filter * not_in_pipeline()
Value used to mark "not in pipeline".
basic_tls< intptr_t > end_of_input_tls_t
for parallel filters that accepts NULLs, thread-local flag for reaching end_of_input
const unsigned char my_filter_mode
Storage for filter mode and dynamically checked implementation version.
auto first(Container &c) -> decltype(begin(c))
Used to form groups of tasks.
A stage in a pipeline served by a user thread.
filter * next_filter_in_pipeline
Pointer to next filter in the pipeline.
bool my_at_start
True if this task has not yet read the input.
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 new_size
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
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.
bool is_ordered
True for ordered filter, false otherwise.
void reset()
Roughly equivalent to the constructor of input stage task.
Base class for user-defined tasks.
void reset()
Set to initial state (no object, no token)
filter * filter_list
Pointer to first filter in the pipeline.
pointer allocate(size_type n, const void *hint=0)
Allocate space for n objects, starting on a cache/sector line.
~input_buffer()
Destroy the buffer.
void remove_filter(filter &filter_)
Remove filter from pipeline.
void deallocate(pointer p, size_type)
Free block of memory that starts on a cache line.
void clear_filters()
Does clean up if pipeline is cancelled or exception occurred.
size_type array_size
Size of array.
task * execute() __TBB_override
Should be overridden by derived classes.
filter * filter_end
Pointer to location where address of next filter to be added should be stored.
A lock that occupies a single byte.
bool has_thread_bound_filters
True if the pipeline contains a thread-bound filter; false otherwise.
bool return_item(task_info &info, bool advance)
return an item, invalidate the queued item, but only advance if the filter
bool is_ordered() const
True if filter must receive stream in order.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
Token my_token
Invalid unless a task went through an ordered stage.
bool has_item()
true if the current low_token is valid.
void __TBB_EXPORTED_METHOD add_filter(filter &filter_)
Add filter to end of pipeline.
result_type internal_process_item(bool is_blocking)
Internal routine for item processing.
bool put_token(task_info &info_, bool force_put=false)
Put a token into the buffer.
bool object_may_be_null()
true if an input filter can emit null
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 * lock
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.
stage_task(pipeline &pipeline, filter *filter_, const task_info &info)
Construct stage_task for a subsequent stage in a pipeline.
pipeline * my_pipeline
Pointer to the pipeline.
bool my_token_ready
False until my_token is set.
static const unsigned char exact_exception_propagation
7th bit defines exception propagation mode expected by the application.
#define __TBB_PIPELINE_VERSION(x)
atomic< internal::Token > input_tokens
Number of idle tokens waiting for input stage.
static const size_type initial_buffer_size
Initial size for "array".
Represents acquisition of a mutex.
friend class internal::pipeline_cleaner
semaphore * my_sem
for thread-bound filter, semaphore for waiting, NULL otherwise.
task_info * array
Array of deferred tasks that cannot yet start executing.
void set_my_tls_end_of_input()
spin_mutex array_mutex
Serializes updates.
void push_back(task &task)
Push task onto back of list.
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 sync_releasing
void note_done(Token token, StageTask &spawner)
Note that processing of a token is finished.
void poison_pointer(T *__TBB_atomic &)
#define ITT_NOTIFY(name, obj)
This structure is used to store task information in a input buffer.
void __TBB_EXPORTED_METHOD inject_token(task &self)
Not used, but retained to satisfy old export files.
pipeline_root_task(pipeline &pipeline)
virtual void finalize(void *)
Destroys item if pipeline was cancelled.
atomic< internal::Token > token_counter
Global counter of tokens.
end_of_input_tls_t end_of_input_tls
bool is_cancelled() const
Returns true if the context has received cancellation request.
bool my_tls_end_of_input()
void set_ref_count(int count)
Set reference count.
stage_task(pipeline &pipeline)
Construct stage_task for first stage in a pipeline.
void grow(size_type minimum_size)
Resize "array".
bool is_bound
True for thread-bound filter, false otherwise.
void recycle_as_continuation()
Change this to be a continuation of its former self.
task * execute() __TBB_override
The virtual task execution method.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
bool is_bound() const
True if filter is thread-bound.
void __TBB_EXPORTED_METHOD clear()
Remove all filters from the pipeline.
void __TBB_EXPORTED_FUNC handle_perror(int error_code, const char *aux_info)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info.
bool end_of_input_tls_allocated
void __TBB_EXPORTED_METHOD set_end_of_input()
Token high_token
Used for out of order buffer, and for assigning my_token if is_ordered and my_token not already assig...
static const unsigned char version_mask
internal::input_buffer * my_input_buffer
Buffer for incoming tokens, or NULL if not required.
void create_sema(size_t initial_tokens)
void spawn_stage_task(const task_info &info)
Creates and spawns stage_task from task_info.
input_buffer(bool is_ordered_, bool is_bound_)
Construct empty buffer.
#define __TBB_TASK_GROUP_CONTEXT
friend class internal::pipeline_root_task
Edsger Dijkstra's counting semaphore.
bool end_of_input
False until fetch_input returns NULL.