void put(int key, int val) { // this will do // unique_lock<shared_mutex> lk(s_mtx); int hash_key = hash(key); rw_lock.WriteLock(); for(auto it = m_map[hash_key].begin(); it != m_map[hash_key].end(); it++) { if((*it).first == key) { (*it).first = key; (*it).second = val; rw_lock.WriteUnLock(); return; } } // new key, insert m_map[hash_key].push_front({key, val}); rw_lock.WriteUnLock(); }