| 303 | }; |
| 304 | |
| 305 | task* stage_task::execute() { |
| 306 | __TBB_ASSERT( !my_at_start || !my_object, NULL ); |
| 307 | __TBB_ASSERT( !my_filter->is_bound(), NULL ); |
| 308 | if( my_at_start ) { |
| 309 | if( my_filter->is_serial() ) { |
| 310 | my_object = (*my_filter)(my_object); |
| 311 | if( my_object || ( my_filter->object_may_be_null() && !my_pipeline.end_of_input) ) |
| 312 | { |
| 313 | if( my_filter->is_ordered() ) { |
| 314 | my_token = my_pipeline.token_counter++; // ideally, with relaxed semantics |
| 315 | my_token_ready = true; |
| 316 | } else if( (my_filter->my_filter_mode & my_filter->version_mask) >= __TBB_PIPELINE_VERSION(5) ) { |
| 317 | if( my_pipeline.has_thread_bound_filters ) |
| 318 | my_pipeline.token_counter++; // ideally, with relaxed semantics |
| 319 | } |
| 320 | if( !my_filter->next_filter_in_pipeline ) { // we're only filter in pipeline |
| 321 | reset(); |
| 322 | goto process_another_stage; |
| 323 | } else { |
| 324 | ITT_NOTIFY( sync_releasing, &my_pipeline.input_tokens ); |
| 325 | if( --my_pipeline.input_tokens>0 ) |
| 326 | spawn( *new( allocate_additional_child_of(*parent()) ) stage_task( my_pipeline ) ); |
| 327 | } |
| 328 | } else { |
| 329 | my_pipeline.end_of_input = true; |
| 330 | return NULL; |
| 331 | } |
| 332 | } else /*not is_serial*/ { |
| 333 | if( my_pipeline.end_of_input ) |
| 334 | return NULL; |
| 335 | if( (my_filter->my_filter_mode & my_filter->version_mask) >= __TBB_PIPELINE_VERSION(5) ) { |
| 336 | if( my_pipeline.has_thread_bound_filters ) |
| 337 | my_pipeline.token_counter++; |
| 338 | } |
| 339 | ITT_NOTIFY( sync_releasing, &my_pipeline.input_tokens ); |
| 340 | if( --my_pipeline.input_tokens>0 ) |
| 341 | spawn( *new( allocate_additional_child_of(*parent()) ) stage_task( my_pipeline ) ); |
| 342 | my_object = (*my_filter)(my_object); |
| 343 | if( !my_object && (!my_filter->object_may_be_null() || my_filter->my_input_buffer->my_tls_end_of_input()) ) |
| 344 | { |
| 345 | my_pipeline.end_of_input = true; |
| 346 | if( (my_filter->my_filter_mode & my_filter->version_mask) >= __TBB_PIPELINE_VERSION(5) ) { |
| 347 | if( my_pipeline.has_thread_bound_filters ) |
| 348 | my_pipeline.token_counter--; // fix token_counter |
| 349 | } |
| 350 | return NULL; |
| 351 | } |
| 352 | } |
| 353 | my_at_start = false; |
| 354 | } else { |
| 355 | my_object = (*my_filter)(my_object); |
| 356 | if( my_filter->is_serial() ) |
| 357 | my_filter->my_input_buffer->note_done(my_token, *this); |
| 358 | } |
| 359 | my_filter = my_filter->next_filter_in_pipeline; |
| 360 | if( my_filter ) { |
| 361 | // There is another filter to execute. |
| 362 | if( my_filter->is_serial() ) { |
no test coverage detected