17 #ifndef __TBB_concurrent_lru_cache_H 18 #define __TBB_concurrent_lru_cache_H 20 #if ! TBB_PREVIEW_CONCURRENT_LRU_CACHE 21 #error Set TBB_PREVIEW_CONCURRENT_LRU_CACHE to include concurrent_lru_cache.h 29 #if __TBB_CPP11_RVALUE_REF_PRESENT 37 namespace interface6 {
40 template <
typename key_type,
typename value_type,
typename value_functor_type = value_type (*)(key_type) >
103 #if !__TBB_CPP11_RVALUE_REF_PRESENT 106 typename map_storage_type::reference my_map_record_ref;
107 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) {};
116 operator bool()
const {
119 #if __TBB_CPP11_RVALUE_REF_PRESENT 122 __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?");
123 src.my_cache_pointer = NULL;
124 src.my_map_record_ptr = NULL;
127 __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?");
133 src.my_cache_pointer = NULL;
134 src.my_map_record_ptr = NULL;
147 operator handle_move_t(){
150 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 162 #if __TBB_CPP11_RVALUE_REF_PRESENT 173 __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?");
175 typename map_storage_type::pointer map_record_ptr =
h.my_map_record_ptr;
176 h.my_cache_pointer = NULL;
177 h.my_map_record_ptr = NULL;
178 return handle_move_t(*cache_pointer, *map_record_ptr);
180 #endif // __TBB_CPP11_RVALUE_REF_PRESENT 200 static_cast<retrieve_aggregator_operation*>(
this)->handle(container);
202 static_cast<signal_end_of_usage_aggregator_operation*>(
this)->handle(container);
230 op_list=op_list->
next;
236 typename map_storage_type::reference
retrieve_serial(key_type k,
bool& is_new_value_needed){
240 is_new_value_needed =
true;
242 typename lru_list_type::iterator list_it = it->second.my_lru_list_iterator;
244 __TBB_ASSERT(!it->second.my_ref_counter,
"item to be evicted should not have a live references");
248 it->second.my_lru_list_iterator=
my_lru_list.end();
251 ++(it->second.my_ref_counter);
256 typename map_storage_type::iterator it =
my_map_storage.find(map_record_ref.first);
258 __TBB_ASSERT(&(*it) == &map_record_ref,
"dangling reference has been returned to outside world? data race ?");
260 "object in use should not be in list of unused objects ");
261 if (! --(it->second.my_ref_counter)){
266 for (
size_t i=0; i<number_of_elements_to_evict; ++i){
267 typename map_storage_type::iterator it_to_evict =
my_lru_list.back();
268 __TBB_ASSERT(!it_to_evict->second.my_ref_counter,
"item to be evicted should not have a live references");
274 it->second.my_lru_list_iterator =
my_lru_list.begin();
280 using interface6::concurrent_lru_cache;
283 #endif //__TBB_concurrent_lru_cache_H 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)
void initialize_handler(handler_type h)
aggregator_type my_aggregator
std::map< key_type, map_value_type > map_storage_type
friend handle_object && move(handle_object &h)
bool is_new_value_needed()
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
uintptr_t status
Zero value means "wait" status, all other values are "user" specified values and are defined into the...
ref_counter_type my_ref_counter
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
aggregated_operation base class
void signal_end_of_usage(typename map_storage_type::reference value_ref)
bool my_is_new_value_needed
void handle(self_type &container)
void signal_end_of_usage_serial(typename map_storage_type::reference map_record_ref)
void handle(self_type &container)
std::list< typename map_storage_type::iterator > lru_list_type
void itt_store_word_with_release(tbb::atomic< T > &dst, U src)
void execute(operation_type *op)
handle_object(concurrent_lru_cache &cache_ref, typename map_storage_type::reference value_ref)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void move(tbb_thread &t1, tbb_thread &t2)
std::size_t ref_counter_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 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
handle_object & operator=(handle_object &&src)
map_storage_type::reference my_map_record_ref
void __TBB_store_with_release(volatile T &location, V value)
handle_object operator[](key_type k)
map_storage_type my_map_storage
lru_list_type::iterator my_lru_list_iterator
map_storage_type::reference result()
void cast_and_handle(self_type &container)
std::size_t const my_number_of_lru_history_items
lru_list_type my_lru_list
Base class for types that should not be assigned.
concurrent_lru_cache self_type
void handle_operations(aggregator_operation *op_list)
value_functor_type value_function_type
signal_end_of_usage_aggregator_operation(typename map_storage_type::reference map_record_ref)
e_op_type my_operation_type
tbb::internal::aggregating_functor< self_type, aggregated_operation_type > aggregator_function_type
retrieve_aggregator_operation(key_type key)
aggregator_operation aggregated_operation_type
map_storage_type::pointer my_result_map_record_pointer
value_function_type my_value_function
handle_object(handle_object &&src)
concurrent_lru_cache * my_cache_pointer
map_storage_type::pointer my_map_record_ptr
concurrent_lru_cache(value_function_type f, std::size_t number_of_lru_history_items)
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