예제 #1
0
 bool blockingGet(const K& key, V& value) {
     size_t index = _hasher(key) % _size;
     boost::shared_lock<boost::shared_mutex> shared_lock(_mutexs[index]);
     typename boost::unordered_map<K, V>::iterator it = _maps[index].find(key);
     
     if (it == _maps[index].end()) {
         return false;
     }
     
     value = _maps[index][key];
     return true;
 }
예제 #2
0
 void blockingSet(const K& key, const V& value) {
     size_t index = _hasher(key) % _size;
     boost::unique_lock<boost::shared_mutex> unique_lock(_mutexs[index]);
     _maps[index][key] = value;
 }
예제 #3
0
 size_t hash(KeyType const &k) const { return _hasher(k) % _values.capacity(); }