9 # include <tbb/concurrent_hash_map.h>
16 template <
typename Record>
20 static const unsigned int DIVSIZE=1;
21 typedef tbb::concurrent_hash_map<HashKey, Record, TBBHashCompare>
table_t;
22 typedef typename table_t::accessor accessor;
24 typedef hash_map<
HashKey, Record
25 # ifdef USE_BOOST_POOL_ALLOCATOR
27 , std::equal_to<HashKey>
28 , osl::stl::fast_pool_allocator<std::pair<const HashKey,Record> >
34 static const unsigned int DIVSIZE=16;
35 CArray<Mutex,DIVSIZE> mutex;
37 static const unsigned int DIVSIZE=1;
41 # ifdef USE_GPL_POOL_ALLOCATOR
52 :
capacity(c), num_cache_hit(0), num_record_after_full(0)
55 for(
size_t i=0;i<DIVSIZE;i++)
64 for(
size_t i=0;i<DIVSIZE;i++){
68 num_record_after_full = 0;
73 for(
size_t i=0;i<DIVSIZE;i++)
74 ret+=tables[i].
size();
82 if(!tables[i].
find(it,key))
return 0;
83 # ifndef OSL_USE_RACE_DETECTOR
88 typename table_t::iterator pos = tables[i].find(key);
89 if (pos == tables[i].end())
91 # ifndef OSL_USE_RACE_DETECTOR
106 unsigned long val=key.signature();
107 return (val>>24)%DIVSIZE;
113 int i=keyToIndex(key);
114 #if (defined OSL_SMP) && (! defined USE_TBB_HASH)
117 return findInLock(key,i);
122 const int i=keyToIndex(key);
123 #if (defined OSL_SMP) && (! defined USE_TBB_HASH)
126 const size_t current_size = tables[i].size();
127 if (current_size <
capacity/DIVSIZE)
131 tables[i].insert(it, key);
132 Record *record = &it->second;
134 Record *record = &tables[i].operator[](key);
136 #ifndef OSL_USE_RACE_DETECTOR
137 if (current_size == tables[i].
size())
143 Record *
result = findInLock(key,i);
148 std::cerr <<
"table full " <<
size() <<
" " <<
capacity <<
"\n";
150 ++num_record_after_full;
153 if (num_record_after_full++ == 0)
162 template <
typename Record>
165 : table(new
Table(capacity))
169 template <
typename Record>
174 template <
typename Record>
181 template <
typename Record>
186 return table->allocate(key);
189 template <
typename Record>
194 return table->find(key);
197 template <
typename Record>
202 return table->find(key);
205 template <
typename Record>
209 return table->size();
212 template <
typename Record>
216 return table->capacity;
219 template <
typename Record>
223 return table->num_cache_hit;
226 template <
typename Record>
230 return table->num_record_after_full;
233 template <
typename Record>
237 return Table::DIVSIZE;