Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
internal::broadcast_cache< T, M > Class Template Reference

A cache of successors that are broadcast to. More...

#include <_flow_graph_cache_impl.h>

Inheritance diagram for internal::broadcast_cache< T, M >:
Collaboration diagram for internal::broadcast_cache< T, M >:

Public Member Functions

 broadcast_cache ()
 
tasktry_put_task (const T &t) __TBB_override
 
bool gather_successful_try_puts (const T &t, task_list &tasks)
 
- Public Member Functions inherited from internal::successor_cache< T, spin_rw_mutex >
 successor_cache ()
 
void set_owner (owner_type *owner)
 
virtual ~successor_cache ()
 
void register_successor (successor_type &r)
 
void remove_successor (successor_type &r)
 
bool empty ()
 
void clear ()
 
virtual tasktry_put_task (const T &t)=0
 

Private Types

typedef M mutex_type
 
typedef successor_cache< T, M >::successors_type successors_type
 

Additional Inherited Members

- Protected Types inherited from internal::successor_cache< T, spin_rw_mutex >
typedef spin_rw_mutex mutex_type
 
typedef receiver< T > successor_type
 
typedef receiver< T > * pointer_type
 
typedef sender< T > owner_type
 
typedef std::list< pointer_typesuccessors_type
 
- Protected Attributes inherited from internal::successor_cache< T, spin_rw_mutex >
mutex_type my_mutex
 
successors_type my_successors
 
owner_typemy_owner
 

Detailed Description

template<typename T, typename M = spin_rw_mutex>
class internal::broadcast_cache< T, M >

A cache of successors that are broadcast to.

Definition at line 465 of file _flow_graph_cache_impl.h.

Member Typedef Documentation

◆ mutex_type

template<typename T , typename M = spin_rw_mutex>
typedef M internal::broadcast_cache< T, M >::mutex_type
private

Definition at line 466 of file _flow_graph_cache_impl.h.

◆ successors_type

template<typename T , typename M = spin_rw_mutex>
typedef successor_cache<T,M>::successors_type internal::broadcast_cache< T, M >::successors_type
private

Definition at line 467 of file _flow_graph_cache_impl.h.

Constructor & Destructor Documentation

◆ broadcast_cache()

template<typename T , typename M = spin_rw_mutex>
internal::broadcast_cache< T, M >::broadcast_cache ( )
inline

Definition at line 471 of file _flow_graph_cache_impl.h.

471{}

Member Function Documentation

◆ gather_successful_try_puts()

template<typename T , typename M = spin_rw_mutex>
bool internal::broadcast_cache< T, M >::gather_successful_try_puts ( const T &  t,
task_list &  tasks 
)
inline

Definition at line 512 of file _flow_graph_cache_impl.h.

512 {
513#endif // __TBB_PREVIEW_ASYNC_MSG
514 bool upgraded = true;
515 bool is_at_least_one_put_successful = false;
516 typename mutex_type::scoped_lock l(this->my_mutex, upgraded);
517 typename successors_type::iterator i = this->my_successors.begin();
518 while ( i != this->my_successors.end() ) {
519 task * new_task = (*i)->try_put_task(t);
520 if(new_task) {
521 ++i;
522 if(new_task != SUCCESSFULLY_ENQUEUED) {
523 tasks.push_back(*new_task);
524 }
525 is_at_least_one_put_successful = true;
526 }
527 else { // failed
528 if ( (*i)->register_predecessor(*this->my_owner) ) {
529 if (!upgraded) {
530 l.upgrade_to_writer();
531 upgraded = true;
532 }
533 i = this->my_successors.erase(i);
534 } else {
535 ++i;
536 }
537 }
538 }
539 return is_at_least_one_put_successful;
540 }
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
static tbb::task *const SUCCESSFULLY_ENQUEUED

References tbb::flow::internal::SUCCESSFULLY_ENQUEUED, and task.

◆ try_put_task()

template<typename T , typename M = spin_rw_mutex>
task * internal::broadcast_cache< T, M >::try_put_task ( const T &  t)
inlinevirtual

Implements internal::successor_cache< T, spin_rw_mutex >.

Definition at line 478 of file _flow_graph_cache_impl.h.

478 {
479#endif // __TBB_PREVIEW_ASYNC_MSG
480 task * last_task = NULL;
481 bool upgraded = true;
482 typename mutex_type::scoped_lock l(this->my_mutex, upgraded);
483 typename successors_type::iterator i = this->my_successors.begin();
484 while ( i != this->my_successors.end() ) {
485 task *new_task = (*i)->try_put_task(t);
486 // workaround for icc bug
487 graph& graph_ref = (*i)->graph_reference();
488 last_task = combine_tasks(graph_ref, last_task, new_task); // enqueue if necessary
489 if(new_task) {
490 ++i;
491 }
492 else { // failed
493 if ( (*i)->register_predecessor(*this->my_owner) ) {
494 if (!upgraded) {
495 l.upgrade_to_writer();
496 upgraded = true;
497 }
498 i = this->my_successors.erase(i);
499 } else {
500 ++i;
501 }
502 }
503 }
504 return last_task;
505 }
static tbb::task * combine_tasks(graph &g, tbb::task *left, tbb::task *right)
Definition: flow_graph.h:199

References tbb::flow::interface11::combine_tasks(), and task.

Referenced by internal::indexer_node_base< InputTuple, OutputType, StructTypes >::handle_operations(), internal::join_node_base< JP, InputTuple, OutputTuple >::handle_operations(), internal::function_output< Output >::try_put_task(), and internal::multifunction_output< Output >::try_put_task().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file:

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.