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)
task * | subscribe (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
T | my_data
subscriber_list_type | my_clients

## Detailed Description

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

Definition at line 27 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 29 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 114 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 31 of file _flow_graph_async_msg_impl.h.

: my_graph(nullptr) {
my_data_ready.store<tbb::relaxed>(false);
}
tbb::relaxed
@ relaxed
No ordering.
Definition: atomic.h:61
internal::async_storage::my_graph
graph * my_graph
Definition: _flow_graph_async_msg_impl.h:110
internal::async_storage::my_data_ready
tbb::atomic< bool > my_data_ready
Definition: _flow_graph_async_msg_impl.h:112

References internal::async_storage< T >::my_data_ready, and tbb::relaxed.

## ~async_storage()

template<typename T >

internal::async_storage< T >::~async_storage | ( |  | ) |

inline

Definition at line 35 of file _flow_graph_async_msg_impl.h.

{
// Release reference to the graph if async_storage
// was destructed before set() call
if (my_graph) {
my_graph->release_wait();
my_graph = nullptr;
}
}

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 45 of file _flow_graph_async_msg_impl.h.

: my_graph(nullptr), my_data( std::forward<C>(data) ) {
using namespace tbb::internal;
__TBB_STATIC_ASSERT( (is_same_type<typename strip<C>::type, typename strip<T>::type>::value), "incoming type must be T" );
my_data_ready.store<tbb::relaxed>(true);
}
__TBB_STATIC_ASSERT
#define __TBB_STATIC_ASSERT(condition, msg)
Definition: tbb_stddef.h:553
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 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 * data
Definition: ittnotify_static.h:198
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 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
Definition: ittnotify_static.h:192
tbb::internal
Identifiers declared inside namespace internal should never be used directly by client code.
Definition: atomic.h:65
internal::async_storage::my_data
T my_data
Definition: _flow_graph_async_msg_impl.h:113
tbb::internal::strip::type
T type
Definition: _template_helpers.h:38
tbb::internal::is_same_type
Detects whether two given types are the same.
Definition: _template_helpers.h:61

References __TBB_STATIC_ASSERT, internal::async_storage< T >::my_data_ready, tbb::relaxed, and value.

## Member Function Documentation

## set()

template<typename T >
template<typename C >

bool internal::async_storage< T >::set | ( | C && | data | ) |

inline

Definition at line 53 of file _flow_graph_async_msg_impl.h.

{
using namespace tbb::internal;
__TBB_STATIC_ASSERT( (is_same_type<typename strip<C>::type, typename strip<T>::type>::value), "incoming type must be T" );
{
tbb::spin_mutex::scoped_lock locker(my_mutex);
if (my_data_ready.load<tbb::relaxed>()) {
__TBB_ASSERT(false, "double set() call");
return false;
}
my_data = std::forward<C>(data);
my_data_ready.store<tbb::release>(true);
}
// Thread sync is on my_data_ready flag
for (typename subscriber_list_type::iterator it = my_clients.begin(); it != my_clients.end(); ++it) {
(*it)->try_put(my_data);
}
// Data was sent, release reference to the graph
if (my_graph) {
my_graph->release_wait();
my_graph = nullptr;
}
return true;
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::release
@ release
Release.
Definition: atomic.h:59
internal::async_storage::my_mutex
tbb::spin_mutex my_mutex
Definition: _flow_graph_async_msg_impl.h:111
internal::async_storage::my_clients
subscriber_list_type my_clients
Definition: _flow_graph_async_msg_impl.h:115
tbb::spin_mutex::scoped_lock
Represents acquisition of a mutex.
Definition: spin_mutex.h:53

References __TBB_ASSERT, __TBB_STATIC_ASSERT, data, 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, and value.

## subscribe()

template<typename T >

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

inline

Definition at line 83 of file _flow_graph_async_msg_impl.h.

{
if (! my_data_ready.load<tbb::acquire>())
{
tbb::spin_mutex::scoped_lock locker(my_mutex);
if (! my_data_ready.load<tbb::relaxed>()) {
#if TBB_USE_ASSERT
for (typename subscriber_list_type::iterator it = my_clients.begin(); it != my_clients.end(); ++it) {
__TBB_ASSERT(*it != &client, "unexpected double subscription");
}
#endif // TBB_USE_ASSERT
// Increase graph lifetime
my_graph = &g;
my_graph->reserve_wait();
// Subscribe
my_clients.push_back(&client);
return SUCCESSFULLY_ENQUEUED;
}
}
__TBB_ASSERT(my_data_ready.load<tbb::relaxed>(), "data is NOT ready");
return client.try_put_task(my_data);
}
tbb::acquire
@ acquire
Acquire.
Definition: atomic.h:57
tbb::flow::internal::SUCCESSFULLY_ENQUEUED
static tbb::task *const SUCCESSFULLY_ENQUEUED
Definition: _flow_graph_impl.h:61

References __TBB_ASSERT, tbb::acquire, 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.

## Member Data Documentation

## my_clients

template<typename T >

subscriber_list_type internal::async_storage< T >::my_clients

private

Definition at line 115 of file _flow_graph_async_msg_impl.h.

Referenced by internal::async_storage< T >::set(), and internal::async_storage< T >::subscribe().

## my_data

template<typename T >

T internal::async_storage< T >::my_data

private

Definition at line 113 of file _flow_graph_async_msg_impl.h.

Referenced by internal::async_storage< T >::set(), and internal::async_storage< T >::subscribe().

## my_data_ready

template<typename T >

tbb::atomic<bool> internal::async_storage< T >::my_data_ready

private

Definition at line 112 of file _flow_graph_async_msg_impl.h.

Referenced by internal::async_storage< T >::async_storage(), internal::async_storage< T >::set(), and internal::async_storage< T >::subscribe().

## my_graph

template<typename T >

graph* internal::async_storage< T >::my_graph

private

Definition at line 110 of file _flow_graph_async_msg_impl.h.

Referenced by internal::async_storage< T >::set(), internal::async_storage< T >::subscribe(), and internal::async_storage< T >::~async_storage().

## my_mutex

template<typename T >

tbb::spin_mutex internal::async_storage< T >::my_mutex

private

Definition at line 111 of file _flow_graph_async_msg_impl.h.

Referenced by internal::async_storage< T >::set(), and internal::async_storage< T >::subscribe().

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

- _flow_graph_async_msg_impl.h

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.