21 #ifndef __TBB_concurrent_lru_cache_H 22 #define __TBB_concurrent_lru_cache_H 24 #if ! TBB_PREVIEW_CONCURRENT_LRU_CACHE 25 #error Set TBB_PREVIEW_CONCURRENT_LRU_CACHE to include concurrent_lru_cache.h 33 #if __TBB_CPP11_RVALUE_REF_PRESENT 41 namespace interface6 {
44 template <
typename key_type,
typename value_type,
typename value_functor_type = value_type (*)(key_type) >
107 #if !__TBB_CPP11_RVALUE_REF_PRESENT 110 typename map_storage_type::reference my_map_record_ref;
111 handle_move_t(
concurrent_lru_cache & cache_ref,
typename map_storage_type::reference value_ref):my_cache_ref(cache_ref),my_map_record_ref(value_ref) {};
120 operator bool()
const {
123 #if __TBB_CPP11_RVALUE_REF_PRESENT 126 __TBB_ASSERT((src.my_cache_pointer && src.my_map_record_ptr) || (!src.my_cache_pointer && !src.my_map_record_ptr),
"invalid state of moving object?");
127 src.my_cache_pointer = NULL;
128 src.my_map_record_ptr = NULL;
131 __TBB_ASSERT((src.my_cache_pointer && src.my_map_record_ptr) || (!src.my_cache_pointer && !src.my_map_record_ptr),
"invalid state of moving object?");
137 src.my_cache_pointer = NULL;
138 src.my_map_record_ptr = NULL;
151 operator handle_move_t(){
154 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 166 #if __TBB_CPP11_RVALUE_REF_PRESENT 177 __TBB_ASSERT((
h.my_cache_pointer &&
h.my_map_record_ptr) || (!
h.my_cache_pointer && !
h.my_map_record_ptr),
"invalid state of moving object?");
179 typename map_storage_type::pointer map_record_ptr =
h.my_map_record_ptr;
180 h.my_cache_pointer = NULL;
181 h.my_map_record_ptr = NULL;
182 return handle_move_t(*cache_pointer, *map_record_ptr);
184 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 204 static_cast<retrieve_aggregator_operation*>(
this)->handle(container);
206 static_cast<signal_end_of_usage_aggregator_operation*>(
this)->handle(container);
234 op_list=op_list->
next;
240 typename map_storage_type::reference
retrieve_serial(key_type k,
bool& is_new_value_needed){
244 is_new_value_needed =
true;
246 typename lru_list_type::iterator list_it = it->second.my_lru_list_iterator;
248 __TBB_ASSERT(!it->second.my_ref_counter,
"item to be evicted should not have a live references");
252 it->second.my_lru_list_iterator=
my_lru_list.end();
255 ++(it->second.my_ref_counter);
260 typename map_storage_type::iterator it =
my_map_storage.find(map_record_ref.first);
262 __TBB_ASSERT(&(*it) == &map_record_ref,
"dangling reference has been returned to outside world? data race ?");
264 "object in use should not be in list of unused objects ");
265 if (! --(it->second.my_ref_counter)){
270 for (
size_t i=0; i<number_of_elements_to_evict; ++i){
271 typename map_storage_type::iterator it_to_evict =
my_lru_list.back();
272 __TBB_ASSERT(!it_to_evict->second.my_ref_counter,
"item to be evicted should not have a live references");
278 it->second.my_lru_list_iterator =
my_lru_list.begin();
284 using interface6::concurrent_lru_cache;
287 #endif //__TBB_concurrent_lru_cache_H
lru_list_type::iterator my_lru_list_iterator
e_op_type my_operation_type
std::map< key_type, map_value_type > map_storage_type
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 h
map_storage_type::pointer my_map_record_ptr
void handle(self_type &container)
map_storage_type::reference my_map_record_ref
void execute(operation_type *op)
concurrent_lru_cache * my_cache_pointer
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
concurrent_lru_cache(value_function_type f, std::size_t number_of_lru_history_items)
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
handle_object operator[](key_type k)
aggregator_type my_aggregator
concurrent_lru_cache self_type
handle_object(concurrent_lru_cache &cache_ref, typename map_storage_type::reference value_ref)
friend handle_object && move(handle_object &h)
ref_counter_type my_ref_counter
map_storage_type::reference retrieve_serial(key_type k, bool &is_new_value_needed)
value_functor_type value_function_type
signal_end_of_usage_aggregator_operation(typename map_storage_type::reference map_record_ref)
Base class for types that should not be assigned.
void signal_end_of_usage_serial(typename map_storage_type::reference map_record_ref)
void initialize_handler(handler_type h)
handle_object & operator=(handle_object &&src)
bool my_is_new_value_needed
map_storage_type my_map_storage
map_storage_type::reference result()
retrieve_aggregator_operation(key_type key)
std::size_t ref_counter_type
void signal_end_of_usage(typename map_storage_type::reference value_ref)
value_function_type my_value_function
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
tbb::internal::aggregating_functor< self_type, aggregated_operation_type > aggregator_function_type
void cast_and_handle(self_type &container)
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 * key
aggregator_operation aggregated_operation_type
std::list< typename map_storage_type::iterator > lru_list_type
tbb::internal::aggregator< aggregator_function_type, aggregated_operation_type > aggregator_type
void move(tbb_thread &t1, tbb_thread &t2)
lru_list_type my_lru_list
aggregated_operation base class
aggregator_operation(e_op_type operation_type)
map_value_type(value_type const &a_value, ref_counter_type a_ref_counter, typename lru_list_type::iterator a_lru_list_iterator, bool a_is_ready)
uintptr_t status
Zero value means "wait" status, all other values are "user" specified values and are defined into the...
std::size_t const my_number_of_lru_history_items
bool is_new_value_needed()
void handle(self_type &container)
void __TBB_store_with_release(volatile T &location, V value)
map_storage_type::pointer my_result_map_record_pointer
void handle_operations(aggregator_operation *op_list)
handle_object(handle_object &&src)