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

#include <_flow_graph_async_msg_impl.h>

Collaboration diagram for internal::async_storage< T >:

Public Types

typedef receiver< T > async_storage_client
 

Public Member Functions

 async_storage ()
 
 ~async_storage ()
 
template<typename C >
 async_storage (C &&data)
 
template<typename C >
bool set (C &&data)
 
tasksubscribe (async_storage_client &client, graph &g)
 

Private Types

typedef std::vector< async_storage_client * > subscriber_list_type
 

Private Attributes

graph * my_graph
 
tbb::spin_mutex my_mutex
 
tbb::atomic< bool > my_data_ready
 
my_data
 
subscriber_list_type my_clients
 

Detailed Description

template<typename T>
class internal::async_storage< T >

Definition at line 31 of file _flow_graph_async_msg_impl.h.

Member Typedef Documentation

◆ async_storage_client

template<typename T >
typedef receiver<T> internal::async_storage< T >::async_storage_client

Definition at line 33 of file _flow_graph_async_msg_impl.h.

◆ subscriber_list_type

template<typename T >
typedef std::vector<async_storage_client*> internal::async_storage< T >::subscriber_list_type
private

Definition at line 118 of file _flow_graph_async_msg_impl.h.

Constructor & Destructor Documentation

◆ async_storage() [1/2]

template<typename T >
internal::async_storage< T >::async_storage ( )
inline

Definition at line 35 of file _flow_graph_async_msg_impl.h.

35  : my_graph(nullptr) {
37  }
No ordering.
Definition: atomic.h:51
void store(value_type value)
Definition: atomic.h:317

References internal::async_storage< T >::my_data_ready, tbb::relaxed, and tbb::internal::atomic_impl< T >::store().

Here is the call graph for this function:

◆ ~async_storage()

template<typename T >
internal::async_storage< T >::~async_storage ( )
inline

Definition at line 39 of file _flow_graph_async_msg_impl.h.

39  {
40  // Release reference to the graph if async_storage
41  // was destructed before set() call
42  if (my_graph) {
43  my_graph->release_wait();
44  my_graph = nullptr;
45  }
46  }

References internal::async_storage< T >::my_graph.

◆ async_storage() [2/2]

template<typename T >
template<typename C >
internal::async_storage< T >::async_storage ( C &&  data)
inline

Definition at line 49 of file _flow_graph_async_msg_impl.h.

49  : my_graph(nullptr), my_data( std::forward<C>(data) ) {
50  using namespace tbb::internal;
51  __TBB_STATIC_ASSERT( (is_same_type<typename strip<C>::type, typename strip<T>::type>::value), "incoming type must be T" );
52 
54  }
No ordering.
Definition: atomic.h:51
#define __TBB_STATIC_ASSERT(condition, msg)
Definition: tbb_stddef.h:536
Detects whether two given types are the same.
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 * data
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 store(value_type value)
Definition: atomic.h:317
Identifiers declared inside namespace internal should never be used directly by client code.
Definition: atomic.h:55

References __TBB_STATIC_ASSERT, internal::async_storage< T >::my_data_ready, tbb::relaxed, tbb::internal::atomic_impl< T >::store(), and value.

Here is the call graph for this function:

Member Function Documentation

◆ set()

template<typename T >
template<typename C >
bool internal::async_storage< T >::set ( C &&  data)
inline

Definition at line 57 of file _flow_graph_async_msg_impl.h.

57  {
58  using namespace tbb::internal;
59  __TBB_STATIC_ASSERT( (is_same_type<typename strip<C>::type, typename strip<T>::type>::value), "incoming type must be T" );
60 
61  {
63 
65  __TBB_ASSERT(false, "double set() call");
66  return false;
67  }
68 
69  my_data = std::forward<C>(data);
71  }
72 
73  // Thread sync is on my_data_ready flag
74  for (typename subscriber_list_type::iterator it = my_clients.begin(); it != my_clients.end(); ++it) {
75  (*it)->try_put(my_data);
76  }
77 
78  // Data was sent, release reference to the graph
79  if (my_graph) {
80  my_graph->release_wait();
81  my_graph = nullptr;
82  }
83 
84  return true;
85  }
No ordering.
Definition: atomic.h:51
#define __TBB_STATIC_ASSERT(condition, msg)
Definition: tbb_stddef.h:536
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
Detects whether two given types are the same.
value_type load() const
Definition: atomic.h:306
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 * data
Represents acquisition of a mutex.
Definition: spin_mutex.h:54
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 store(value_type value)
Definition: atomic.h:317
Identifiers declared inside namespace internal should never be used directly by client code.
Definition: atomic.h:55
Release.
Definition: atomic.h:49

References __TBB_ASSERT, __TBB_STATIC_ASSERT, data, tbb::internal::atomic_impl< T >::load(), internal::async_storage< T >::my_clients, internal::async_storage< T >::my_data, internal::async_storage< T >::my_data_ready, internal::async_storage< T >::my_graph, internal::async_storage< T >::my_mutex, tbb::relaxed, tbb::release, tbb::internal::atomic_impl< T >::store(), and value.

Here is the call graph for this function:

◆ subscribe()

template<typename T >
task* internal::async_storage< T >::subscribe ( async_storage_client client,
graph &  g 
)
inline

Definition at line 87 of file _flow_graph_async_msg_impl.h.

87  {
89  {
91 
92  if (! my_data_ready.load<tbb::relaxed>()) {
93 #if TBB_USE_ASSERT
94  for (typename subscriber_list_type::iterator it = my_clients.begin(); it != my_clients.end(); ++it) {
95  __TBB_ASSERT(*it != &client, "unexpected double subscription");
96  }
97 #endif // TBB_USE_ASSERT
98 
99  // Increase graph lifetime
100  my_graph = &g;
101  my_graph->reserve_wait();
102 
103  // Subscribe
104  my_clients.push_back(&client);
105  return SUCCESSFULLY_ENQUEUED;
106  }
107  }
108 
109  __TBB_ASSERT(my_data_ready.load<tbb::relaxed>(), "data is NOT ready");
110  return client.try_put_task(my_data);
111  }
static tbb::task *const SUCCESSFULLY_ENQUEUED
No ordering.
Definition: atomic.h:51
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:169
Acquire.
Definition: atomic.h:47
value_type load() const
Definition: atomic.h:306
Represents acquisition of a mutex.
Definition: spin_mutex.h:54

References __TBB_ASSERT, tbb::acquire, tbb::internal::atomic_impl< T >::load(), internal::async_storage< T >::my_clients, internal::async_storage< T >::my_data, internal::async_storage< T >::my_data_ready, internal::async_storage< T >::my_graph, internal::async_storage< T >::my_mutex, tbb::relaxed, and tbb::flow::internal::SUCCESSFULLY_ENQUEUED.

Here is the call graph for this function:

Member Data Documentation

◆ my_clients

template<typename T >
subscriber_list_type internal::async_storage< T >::my_clients
private

◆ my_data

template<typename T >
T internal::async_storage< T >::my_data
private

◆ my_data_ready

◆ my_graph

◆ my_mutex

template<typename T >
tbb::spin_mutex internal::async_storage< T >::my_mutex
private

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

Copyright © 2005-2019 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.