17 #ifndef __TBB_concurrent_lru_cache_H 18 #define __TBB_concurrent_lru_cache_H 20 #define __TBB_concurrent_lru_cache_H_include_area 23 #if ! TBB_PREVIEW_CONCURRENT_LRU_CACHE 24 #error Set TBB_PREVIEW_CONCURRENT_LRU_CACHE to include concurrent_lru_cache.h 32 #if __TBB_CPP11_RVALUE_REF_PRESENT 40 namespace interface6 {
43 template <
typename key_type,
typename value_type,
typename value_functor_type = value_type (*)(key_type) >
106 #if !__TBB_CPP11_RVALUE_REF_PRESENT 109 typename map_storage_type::reference my_map_record_ref;
110 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) {};
119 operator bool()
const {
122 #if __TBB_CPP11_RVALUE_REF_PRESENT 125 __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?");
126 src.my_cache_pointer = NULL;
127 src.my_map_record_ptr = NULL;
130 __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?");
136 src.my_cache_pointer = NULL;
137 src.my_map_record_ptr = NULL;
150 operator handle_move_t(){
153 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 165 #if __TBB_CPP11_RVALUE_REF_PRESENT 176 __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?");
178 typename map_storage_type::pointer map_record_ptr =
h.my_map_record_ptr;
179 h.my_cache_pointer = NULL;
180 h.my_map_record_ptr = NULL;
181 return handle_move_t(*cache_pointer, *map_record_ptr);
183 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 203 static_cast<retrieve_aggregator_operation*>(
this)->handle(container);
205 static_cast<signal_end_of_usage_aggregator_operation*>(
this)->handle(container);
233 op_list=op_list->
next;
239 typename map_storage_type::reference
retrieve_serial(key_type k,
bool& is_new_value_needed){
243 is_new_value_needed =
true;
245 typename lru_list_type::iterator list_it = it->second.my_lru_list_iterator;
247 __TBB_ASSERT(!it->second.my_ref_counter,
"item to be evicted should not have a live references");
251 it->second.my_lru_list_iterator=
my_lru_list.end();
254 ++(it->second.my_ref_counter);
259 typename map_storage_type::iterator it =
my_map_storage.find(map_record_ref.first);
261 __TBB_ASSERT(&(*it) == &map_record_ref,
"dangling reference has been returned to outside world? data race ?");
263 "object in use should not be in list of unused objects ");
264 if (! --(it->second.my_ref_counter)){
269 for (
size_t i=0; i<number_of_elements_to_evict; ++i){
270 typename map_storage_type::iterator it_to_evict =
my_lru_list.back();
271 __TBB_ASSERT(!it_to_evict->second.my_ref_counter,
"item to be evicted should not have a live references");
277 it->second.my_lru_list_iterator =
my_lru_list.begin();
283 using interface6::concurrent_lru_cache;
288 #undef __TBB_concurrent_lru_cache_H_include_area 290 #endif //__TBB_concurrent_lru_cache_H void cast_and_handle(self_type &container)
e_op_type my_operation_type
value_function_type my_value_function
concurrent_lru_cache * my_cache_pointer
ref_counter_type my_ref_counter
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
retrieve_aggregator_operation(key_type key)
lru_list_type::iterator my_lru_list_iterator
void handle(self_type &container)
void handle(self_type &container)
void signal_end_of_usage_serial(typename map_storage_type::reference map_record_ref)
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given 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 ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle * key
uintptr_t status
Zero value means "wait" status, all other values are "user" specified values and are defined into the...
std::list< typename map_storage_type::iterator > lru_list_type
std::map< key_type, map_value_type > map_storage_type
Base class for types that should not be assigned.
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
map_storage_type::reference retrieve_serial(key_type k, bool &is_new_value_needed)
tbb::internal::aggregator< aggregator_function_type, aggregated_operation_type > aggregator_type
map_storage_type::pointer my_map_record_ptr
handle_object & operator=(handle_object &&src)
void __TBB_store_with_release(volatile T &location, V value)
std::size_t ref_counter_type
map_storage_type::reference my_map_record_ref
void execute(operation_type *op)
void signal_end_of_usage(typename map_storage_type::reference value_ref)
map_storage_type::pointer my_result_map_record_pointer
void handle_operations(aggregator_operation *op_list)
handle_object(handle_object &&src)
signal_end_of_usage_aggregator_operation(typename map_storage_type::reference map_record_ref)
bool my_is_new_value_needed
handle_object(concurrent_lru_cache &cache_ref, typename map_storage_type::reference value_ref)
aggregated_operation base class
void initialize_handler(handler_type h)
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)
concurrent_lru_cache(value_function_type f, std::size_t number_of_lru_history_items)
friend handle_object && move(handle_object &h)
handle_object operator[](key_type k)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
bool is_new_value_needed()
map_storage_type my_map_storage
aggregator_operation(e_op_type operation_type)
std::size_t const my_number_of_lru_history_items
lru_list_type my_lru_list
aggregator_type my_aggregator
concurrent_lru_cache self_type
value_functor_type value_function_type
map_storage_type::reference result()
tbb::internal::aggregating_functor< self_type, aggregated_operation_type > aggregator_function_type
aggregator_operation aggregated_operation_type
void move(tbb_thread &t1, tbb_thread &t2)