proxygen
ConcurrentHashMapTest.cpp File Reference
#include <folly/concurrency/ConcurrentHashMap.h>
#include <atomic>
#include <memory>
#include <thread>
#include <folly/hash/Hash.h>
#include <folly/portability/GTest.h>
#include <folly/test/DeterministicSchedule.h>

Go to the source code of this file.

Classes

struct  foo
 
struct  Wrapper
 

Macros

#define Atom   std::atomic
 
#define Mutex   std::mutex
 
#define lib   std
 
#define join   t.join()
 

Functions

 DEFINE_int64 (seed, 0,"Seed for random number generators")
 
 TEST (ConcurrentHashMap, MapTest)
 
 TEST (ConcurrentHashMap, MaxSizeTest)
 
 TEST (ConcurrentHashMap, MoveTest)
 
 TEST (ConcurrentHashMap, EmplaceTest)
 
 TEST (ConcurrentHashMap, MapResizeTest)
 
 TEST (ConcurrentHashMap, MapNoCopiesTest)
 
 TEST (ConcurrentHashMap, MapMovableKeysTest)
 
 TEST (ConcurrentHashMap, MapUpdateTest)
 
 TEST (ConcurrentHashMap, MapIterateTest2)
 
 TEST (ConcurrentHashMap, MapIterateTest)
 
 TEST (ConcurrentHashMap, MoveIterateAssignIterate)
 
 TEST (ConcurrentHashMap, EraseTest)
 
 TEST (ConcurrentHashMap, CopyIterator)
 
 TEST (ConcurrentHashMap, EraseInIterateTest)
 
 TEST (ConcurrentHashMap, UpdateStressTest)
 
 TEST (ConcurrentHashMap, EraseStressTest)
 
 TEST (ConcurrentHashMap, IterateStressTest)
 
 TEST (ConcurrentHashMap, insertStressTest)
 
 TEST (ConcurrentHashMap, assignStressTest)
 
 TEST (ConcurrentHashMap, RefcountTest)
 
 TEST (ConcurrentHashMap, Deletion)
 
 TEST (ConcurrentHashMap, DeletionWithErase)
 
 TEST (ConcurrentHashMap, DeletionWithIterator)
 
 TEST (ConcurrentHashMap, DeletionWithForLoop)
 
 TEST (ConcurrentHashMap, DeletionMultiple)
 
 TEST (ConcurrentHashMap, DeletionAssigned)
 
 TEST (ConcurrentHashMap, DeletionMultipleMaps)
 
 TEST (ConcurrentHashMap, ForEachLoop)
 
 TEST (ConcurrentHashMap, IteratorMove)
 

Macro Definition Documentation

#define Atom   std::atomic

Definition at line 301 of file ConcurrentHashMapTest.cpp.

Referenced by folly::hazptr_domain< DeterministicAtomic >::acquire_new_hprec(), array_dtor_full_tc_test(), array_test(), folly::detail::atomic_notification::atomic_notify_all_impl(), folly::test::atomic_notify_one(), folly::detail::atomic_notification::atomic_notify_one_impl(), folly::detail::atomic_notification::atomic_wait_impl(), folly::detail::atomic_notification::atomic_wait_until_impl(), auto_retire_test(), basic_holders_test(), basic_objects_test(), basic_protection_test(), burn(), cleanup_test(), copy_and_move_test(), folly::detail::LifoSemBase< BatonType, Atom >::decrOrPush(), folly::default_hazptr_domain(), folly::hazptr_deleter< T, std::default_delete< T > >::delete_obj(), destruction_test(), deterministicAtomicWaitUntilTests(), folly::hazptr_obj_linked< Atom >::downgrade_link(), folly::test::doWork(), free_function_retire_test(), folly::hazptr_default_domain_helper< std::atomic >::get(), counted_ptr_base< Atom >::getRef(), folly::detail::LifoSemNode< Handoff, Atom >::handoff(), folly::hazptr_domain_push_retired(), folly::detail::hazptr_domain_rcount_threshold(), folly::hazptr_retire(), folly::AccessSpreader< Atom >::initialize(), non_atomic< T >::is_lock_free(), lifo_test(), linked_test(), local_test(), make_counted(), folly::MPMCQueue< T, Atom, true >::maybeUpdateFromClosed(), move_test(), mt_linked_test(), folly::detail::LifoSemHead::operator!=(), folly::hazptr_root< Node, Atom >::operator()(), folly::DefaultWeightFn< T >::operator()(), counted_ptr< T, Atom >::operator==(), folly::hazptr_array< 3, Atom >::operator[](), folly::hazptr_obj< Atom >::pre_retire_check_fail(), priv_dtor_test(), List< T, Atom >::protect_all(), pthrd_mutex_(), pthrd_rwlock_reads(), Node< Atom >::ptr_next(), NodeRC< Mutable, Atom >::push_links(), NodeAuto< Atom >::push_links(), folly::UnboundedQueue< T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom >::Segment::push_links(), run_basic_test(), folly::test::run_basic_test(), run_basic_tests(), run_basic_thread(), folly::test::run_basic_timed_wait_tests(), run_mt_sequencer_thread(), folly::test::run_pingpong_test(), run_pingpong_test(), run_steady_clock_test(), folly::test::run_timed_wait_tmo_tests(), runNeverFailTest(), runNeverFailThread(), runNeverFailUntilThread(), folly::runReader(), runRemoteUnlock(), runTryEnqDeqThread(), folly::hazptr_holder< Atom >::set_hprec(), folly::swap(), swmr_test(), folly::TEST(), TEST(), folly::detail::atomic_notification::toCvStatus(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::tryUnlockTokenlessSharedDeferred(), folly::LockFreeRingBuffer< T, Atom >::turn(), PosixMutex::unlock_shared(), folly::value(), virtual_test(), and folly::AtomicUnorderedInsertMap< Key, Value, Hash, KeyEqual, SkipKeyValueDeletion, Atom, IndexType, Allocator >::zeroFillSlots().

#define join   t.join()

Definition at line 304 of file ConcurrentHashMapTest.cpp.

Referenced by release_docs.WikiBrancher::__init__(), fbcode_builder.FBCodeBuilder::__repr__(), cpp.ast.Parameter::__str__(), cpp.ast.Type::__str__(), upload.SubversionVCS::_CollapseKeywords(), cpp.gmock_class::_GenerateMethods(), cpp.gmock_class::_GenerateMocks(), cpp.ast.AstBuilder::_GenerateOne(), cpp.ast.AstBuilder::_GetClass(), upload.HttpRpcServer::_GetOpener(), cpp.ast._GenericDeclaration::_TypeStringHelper(), pump.Output::Append(), pump::BeautifyCode(), pump.Token::Clone(), cpp.ast.TypeConverter::DeclarationToParts(), cpp.ast._GenericDeclaration::FullName(), gen_trace_event_constants::gen_java(), upload.GitVCS::GenerateDiff(), upload.MercurialVCS::GenerateDiff(), gen_gtest_pred_impl::GenerateHeader(), cpp.gmock_class_test.GenerateMethodsTest::GenerateMethodSource(), cpp.gmock_class_test.GenerateMocksTest::GenerateMocks(), gen_gtest_pred_impl::GenerateUnitTest(), upload.MercurialVCS::GetBaseFile(), cpp.ast.AstBuilder::handle_struct(), upload_gtest::main(), upload_gmock::main(), cpp.gmock_class::main(), make_docker_context::make_docker_context(), wangle::MultiFilePoller::registerFiles(), gtest_throw_on_failure_test::Run(), gtest_throw_on_failure_test.ThrowOnFailureTest::RunAndVerify(), gtest_break_on_failure_unittest.GTestBreakOnFailureUnitTest::RunAndVerify(), gtest_list_tests_unittest.GTestListTestsUnitTest::RunAndVerify(), upload::RunShellWithReturnCode(), folly::runWritesNeverFail(), upload::SplitPatch(), cpp.gmock_class_test.TestCase::StripLeadingWhitespace(), pump::SubString(), TEST(), TEST_F(), gtest_output_test.GTestOutputTest::testOutput(), gen_gtest_pred_impl::TestsForArity(), and cpp.ast.TypeConverter::ToType().

#define lib   std

Definition at line 303 of file ConcurrentHashMapTest.cpp.

Referenced by cmake_minimum_required(), option(), and TEST().

Function Documentation

DEFINE_int64 ( seed  ,
,
"Seed for random number generators"   
)
TEST ( ConcurrentHashMap  ,
MapTest   
)

Definition at line 33 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::assign_if_equal(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::at(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::clear(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::empty(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::erase(), EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_TRUE, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::find(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert_or_assign(), and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::max_load_factor().

33  {
35  foomap.max_load_factor(1.05);
36  EXPECT_TRUE(foomap.empty());
37  EXPECT_EQ(foomap.find(1), foomap.cend());
38  auto r = foomap.insert(1, 0);
39  EXPECT_TRUE(r.second);
40  auto r2 = foomap.insert(1, 0);
41  EXPECT_EQ(r.first->second, 0);
42  EXPECT_EQ(r.first->first, 1);
43  EXPECT_EQ(r2.first->second, 0);
44  EXPECT_EQ(r2.first->first, 1);
45  EXPECT_EQ(r.first, r2.first);
46  EXPECT_TRUE(r.second);
47  EXPECT_FALSE(r2.second);
48  EXPECT_FALSE(foomap.empty());
49  EXPECT_TRUE(foomap.insert(std::make_pair(2, 0)).second);
50  EXPECT_TRUE(foomap.insert_or_assign(2, 0).second);
51  EXPECT_TRUE(foomap.assign_if_equal(2, 0, 3));
52  EXPECT_TRUE(foomap.insert(3, 0).second);
53  EXPECT_NE(foomap.find(1), foomap.cend());
54  EXPECT_NE(foomap.find(2), foomap.cend());
55  EXPECT_EQ(foomap.find(2)->second, 3);
56  EXPECT_EQ(foomap[2], 3);
57  EXPECT_EQ(foomap[20], 0);
58  EXPECT_EQ(foomap.at(20), 0);
59  EXPECT_FALSE(foomap.insert(1, 0).second);
60  auto l = foomap.find(1);
61  foomap.erase(l);
62  EXPECT_FALSE(foomap.erase(1));
63  EXPECT_EQ(foomap.find(1), foomap.cend());
64  auto res = foomap.find(2);
65  EXPECT_NE(res, foomap.cend());
66  EXPECT_EQ(3, res->second);
67  EXPECT_FALSE(foomap.empty());
68  foomap.clear();
69  EXPECT_TRUE(foomap.empty());
70 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ConcurrentHashMap  ,
MaxSizeTest   
)

Definition at line 72 of file ConcurrentHashMapTest.cpp.

References EXPECT_TRUE, i, and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert().

72  {
74  bool insert_failed = false;
75  for (int i = 0; i < 32; i++) {
76  auto res = foomap.insert(0, 0);
77  if (!res.second) {
78  insert_failed = true;
79  }
80  }
81  EXPECT_TRUE(insert_failed);
82 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
MoveTest   
)

Definition at line 84 of file ConcurrentHashMapTest.cpp.

References folly::gen::move.

84  {
86  auto other = std::move(foomap);
87  auto other2 = std::move(other);
88  other = std::move(other2);
89 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TEST ( ConcurrentHashMap  ,
EmplaceTest   
)

Definition at line 113 of file ConcurrentHashMapTest.cpp.

References bar, foo::copied, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::emplace(), EXPECT_EQ, folly::foo, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), foo::moved, and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::try_emplace().

113  {
115  foo bar; // Make sure to test copy
116  foomap.insert(1, bar);
117  EXPECT_EQ(foo::moved, 0);
119  foo::copied = 0;
120  // The difference between emplace and try_emplace:
121  // If insertion fails, try_emplace does not move its argument
122  foomap.try_emplace(1, foo());
123  EXPECT_EQ(foo::moved, 0);
125  foomap.emplace(1, foo());
126  EXPECT_EQ(foo::moved, 1);
128 }
static int copied
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
folly::Singleton< int > bar
static int moved
TEST ( ConcurrentHashMap  ,
MapResizeTest   
)

Definition at line 130 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::erase(), EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_TRUE, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::find(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::reserve().

130  {
132  EXPECT_EQ(foomap.find(1), foomap.cend());
133  EXPECT_TRUE(foomap.insert(1, 0).second);
134  EXPECT_TRUE(foomap.insert(2, 0).second);
135  EXPECT_TRUE(foomap.insert(3, 0).second);
136  EXPECT_TRUE(foomap.insert(4, 0).second);
137  foomap.reserve(512);
138  EXPECT_NE(foomap.find(1), foomap.cend());
139  EXPECT_NE(foomap.find(2), foomap.cend());
140  EXPECT_FALSE(foomap.insert(1, 0).second);
141  EXPECT_TRUE(foomap.erase(1));
142  EXPECT_EQ(foomap.find(1), foomap.cend());
143  auto res = foomap.find(2);
144  EXPECT_NE(res, foomap.cend());
145  if (res != foomap.cend()) {
146  EXPECT_EQ(0, res->second);
147  }
148 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ConcurrentHashMap  ,
MapNoCopiesTest   
)

Definition at line 151 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), EXPECT_EQ, EXPECT_NE, EXPECT_TRUE, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::find(), i, folly::test::operator==(), and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::try_emplace().

151  {
152  struct Uncopyable {
153  int i_;
154  Uncopyable(int i) {
155  i_ = i;
156  }
157  Uncopyable(const Uncopyable& that) = delete;
158  bool operator==(const Uncopyable& o) const {
159  return i_ == o.i_;
160  }
161  };
162  struct Hasher {
163  size_t operator()(const Uncopyable&) const {
164  return 0;
165  }
166  };
168  EXPECT_TRUE(foomap.try_emplace(1, 1).second);
169  EXPECT_TRUE(foomap.try_emplace(2, 2).second);
170  auto res = foomap.find(2);
171  EXPECT_NE(res, foomap.cend());
172 
173  EXPECT_TRUE(foomap.try_emplace(3, 3).second);
174 
175  auto res2 = foomap.find(2);
176  EXPECT_NE(res2, foomap.cend());
177  EXPECT_EQ(&(res->second), &(res2->second));
178 }
bool operator==(const char *c, CStringRange::Sentinel)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
TEST ( ConcurrentHashMap  ,
MapMovableKeysTest   
)

Definition at line 180 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::assign(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::assign_if_equal(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::emplace(), EXPECT_FALSE, EXPECT_TRUE, i, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert_or_assign(), folly::test::operator==(), and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::try_emplace().

180  {
181  struct Movable {
182  int i_;
183  Movable(int i) {
184  i_ = i;
185  }
186  Movable(const Movable&) = delete;
187  Movable(Movable&& o) {
188  i_ = o.i_;
189  o.i_ = 0;
190  }
191  bool operator==(const Movable& o) const {
192  return i_ == o.i_;
193  }
194  };
195  struct Hasher {
196  size_t operator()(const Movable&) const {
197  return 0;
198  }
199  };
201  EXPECT_TRUE(foomap.insert(std::make_pair(Movable(10), Movable(1))).second);
202  EXPECT_TRUE(foomap.assign(Movable(10), Movable(2)));
203  EXPECT_TRUE(foomap.insert(Movable(11), Movable(1)).second);
204  EXPECT_TRUE(foomap.emplace(Movable(12), Movable(1)).second);
205  EXPECT_TRUE(foomap.insert_or_assign(Movable(10), Movable(3)).second);
206  EXPECT_TRUE(foomap.assign_if_equal(Movable(10), Movable(3), Movable(4)));
207  EXPECT_FALSE(foomap.try_emplace(Movable(10), Movable(3)).second);
208  EXPECT_TRUE(foomap.try_emplace(Movable(13), Movable(3)).second);
209 }
bool operator==(const char *c, CStringRange::Sentinel)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ConcurrentHashMap  ,
MapIterateTest2   
)
TEST ( ConcurrentHashMap  ,
MapIterateTest   
)

Definition at line 227 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cbegin(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), count, EXPECT_EQ, EXPECT_NE, EXPECT_TRUE, and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert().

227  {
229  EXPECT_EQ(foomap.cbegin(), foomap.cend());
230  EXPECT_TRUE(foomap.insert(1, 1).second);
231  EXPECT_TRUE(foomap.insert(2, 2).second);
232  auto iter = foomap.cbegin();
233  EXPECT_NE(iter, foomap.cend());
234  EXPECT_EQ(iter->first, 1);
235  EXPECT_EQ(iter->second, 1);
236  ++iter;
237  EXPECT_NE(iter, foomap.cend());
238  EXPECT_EQ(iter->first, 2);
239  EXPECT_EQ(iter->second, 2);
240  ++iter;
241  EXPECT_EQ(iter, foomap.cend());
242 
243  int count = 0;
244  for (auto it = foomap.cbegin(); it != foomap.cend(); ++it) {
245  count++;
246  }
247  EXPECT_EQ(count, 2);
248 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
int * count
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
TEST ( ConcurrentHashMap  ,
MoveIterateAssignIterate   
)

Definition at line 250 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), map(), and folly::gen::move.

250  {
252  Map tmp;
253  Map map{std::move(tmp)};
254 
255  map.insert(0, 0);
256  ++map.cbegin();
258  other.insert(0, 0);
259  map = std::move(other);
260  ++map.cbegin();
261 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unordered_map< int64_t, VecT > Map
static Map map(mapCap)
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
TEST ( ConcurrentHashMap  ,
CopyIterator   
)

Definition at line 271 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cbegin(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), EXPECT_EQ, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

271  {
273  map.insert(0, 0);
274  for (auto cit = map.cbegin(); cit != map.cend(); ++cit) {
275  std::pair<int const, int> const ckv{0, 0};
276  EXPECT_EQ(*cit, ckv);
277  }
278 }
ConstIterator cbegin() const noexcept
ConstIterator cend() const noexcept
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Map map(mapCap)
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
TEST ( ConcurrentHashMap  ,
EraseInIterateTest   
)

Definition at line 280 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cbegin(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::erase(), EXPECT_EQ, EXPECT_GE, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), k, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::size(), and uint64_t.

280  {
282  for (uint64_t k = 0; k < 10; ++k) {
283  foomap.insert(k, k);
284  }
285  EXPECT_EQ(10, foomap.size());
286  for (auto it = foomap.cbegin(); it != foomap.cend();) {
287  if (it->second > 3) {
288  it = foomap.erase(it);
289  } else {
290  ++it;
291  }
292  }
293  EXPECT_EQ(4, foomap.size());
294  for (auto it = foomap.cbegin(); it != foomap.cend(); ++it) {
295  EXPECT_GE(3, it->second);
296  }
297 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_GE(val1, val2)
Definition: gtest.h:1932
KeyT k
TEST ( ConcurrentHashMap  ,
UpdateStressTest   
)

Definition at line 310 of file ConcurrentHashMapTest.cpp.

References Atom, EXPECT_EQ, EXPECT_NE, EXPECT_TRUE, i, folly::hash::jenkins_rev_mix32(), folly::join(), k, m, Mutex, folly::size(), folly::pushmi::detail::t, threads, uint32_t, folly::test::DeterministicSchedule::uniform(), and val.

310  {
311  DeterministicSchedule sched(DeterministicSchedule::uniform(FLAGS_seed));
312 
313  // size must match iters for this test.
314  unsigned size = 128 * 128;
315  unsigned iters = size;
317  unsigned long,
318  unsigned long,
319  std::hash<unsigned long>,
320  std::equal_to<unsigned long>,
321  std::allocator<uint8_t>,
322  8,
323  Atom,
324  Mutex>
325  m(2);
326 
327  for (uint32_t i = 0; i < size; i++) {
328  m.insert(i, i);
329  }
330  std::vector<std::thread> threads;
331  unsigned int num_threads = 32;
332  for (uint32_t t = 0; t < num_threads; t++) {
333  threads.push_back(lib::thread([&, t]() {
334  int offset = (iters * t / num_threads);
335  for (uint32_t i = 0; i < iters / num_threads; i++) {
336  unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
337  k = k % (iters / num_threads) + offset;
338  unsigned long val = 3;
339  {
340  auto res = m.find(k);
341  EXPECT_NE(res, m.cend());
342  EXPECT_EQ(k, res->second);
343  auto r = m.assign(k, res->second);
344  EXPECT_TRUE(r);
345  }
346  {
347  auto res = m.find(k);
348  EXPECT_NE(res, m.cend());
349  EXPECT_EQ(k, res->second);
350  }
351  // Another random insertion to force table resizes
352  val = size + i + offset;
353  EXPECT_TRUE(m.insert(val, val).second);
354  }
355  }));
356  }
357  for (auto& t : threads) {
358  join;
359  }
360 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define Mutex
double val
Definition: String.cpp:273
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
Definition: Hash.h:97
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define Atom
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define join
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
KeyT k
TEST ( ConcurrentHashMap  ,
EraseStressTest   
)

Definition at line 362 of file ConcurrentHashMapTest.cpp.

References Atom, EXPECT_EQ, EXPECT_TRUE, i, folly::hash::jenkins_rev_mix32(), folly::join(), k, m, Mutex, folly::size(), folly::pushmi::detail::t, threads, uint32_t, and folly::test::DeterministicSchedule::uniform().

362  {
363  DeterministicSchedule sched(DeterministicSchedule::uniform(FLAGS_seed));
364 
365  unsigned size = 2;
366  unsigned iters = size * 128 * 2;
368  unsigned long,
369  unsigned long,
370  std::hash<unsigned long>,
371  std::equal_to<unsigned long>,
372  std::allocator<uint8_t>,
373  8,
374  Atom,
375  Mutex>
376  m(2);
377 
378  for (uint32_t i = 0; i < size; i++) {
379  unsigned long k = folly::hash::jenkins_rev_mix32(i);
380  m.insert(k, k);
381  }
382  std::vector<std::thread> threads;
383  unsigned int num_threads = 32;
384  for (uint32_t t = 0; t < num_threads; t++) {
385  threads.push_back(lib::thread([&, t]() {
386  int offset = (iters * t / num_threads);
387  for (uint32_t i = 0; i < iters / num_threads; i++) {
388  unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
389  auto res = m.insert(k, k).second;
390  if (res) {
391  res = m.erase(k);
392  if (!res) {
393  printf("Faulre to erase thread %i val %li\n", t, k);
394  exit(0);
395  }
396  EXPECT_TRUE(res);
397  }
398  res = m.insert(k, k).second;
399  if (res) {
400  res = bool(m.assign(k, k));
401  if (!res) {
402  printf("Thread %i update fail %li res%i\n", t, k, res);
403  exit(0);
404  }
405  EXPECT_TRUE(res);
406  auto result = m.find(k);
407  if (result == m.cend()) {
408  printf("Thread %i lookup fail %li\n", t, k);
409  exit(0);
410  }
411  EXPECT_EQ(k, result->second);
412  }
413  }
414  }));
415  }
416  for (auto& t : threads) {
417  join;
418  }
419 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define Mutex
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
Definition: Hash.h:97
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define Atom
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define join
KeyT k
TEST ( ConcurrentHashMap  ,
IterateStressTest   
)

Definition at line 421 of file ConcurrentHashMapTest.cpp.

References Atom, count, EXPECT_EQ, EXPECT_TRUE, i, folly::hash::jenkins_rev_mix32(), folly::join(), k, m, Mutex, folly::size(), folly::pushmi::detail::t, threads, uint32_t, and folly::test::DeterministicSchedule::uniform().

421  {
422  DeterministicSchedule sched(DeterministicSchedule::uniform(FLAGS_seed));
423 
424  unsigned size = 2;
425  unsigned iters = size * 128 * 2;
427  unsigned long,
428  unsigned long,
429  std::hash<unsigned long>,
430  std::equal_to<unsigned long>,
431  std::allocator<uint8_t>,
432  8,
433  Atom,
434  Mutex>
435  m(2);
436 
437  for (uint32_t i = 0; i < size; i++) {
438  unsigned long k = folly::hash::jenkins_rev_mix32(i);
439  m.insert(k, k);
440  }
441  for (uint32_t i = 0; i < 10; i++) {
442  m.insert(i, i);
443  }
444  std::vector<std::thread> threads;
445  unsigned int num_threads = 32;
446  for (uint32_t t = 0; t < num_threads; t++) {
447  threads.push_back(lib::thread([&, t]() {
448  int offset = (iters * t / num_threads);
449  for (uint32_t i = 0; i < iters / num_threads; i++) {
450  unsigned long k = folly::hash::jenkins_rev_mix32((i + offset));
451  auto res = m.insert(k, k).second;
452  if (res) {
453  res = m.erase(k);
454  if (!res) {
455  printf("Faulre to erase thread %i val %li\n", t, k);
456  exit(0);
457  }
458  EXPECT_TRUE(res);
459  }
460  int count = 0;
461  for (auto it = m.cbegin(); it != m.cend(); ++it) {
462  printf("Item is %li\n", it->first);
463  if (it->first < 10) {
464  count++;
465  }
466  }
467  EXPECT_EQ(count, 10);
468  }
469  }));
470  }
471  for (auto& t : threads) {
472  join;
473  }
474 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define Mutex
uint32_t jenkins_rev_mix32(uint32_t key) noexcept
Definition: Hash.h:97
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define Atom
static map< string, int > m
int * count
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define join
KeyT k
TEST ( ConcurrentHashMap  ,
insertStressTest   
)

Definition at line 476 of file ConcurrentHashMapTest.cpp.

References Atom, EXPECT_FALSE, EXPECT_TRUE, i, folly::join(), m, Mutex, folly::size(), folly::pushmi::detail::t, threads, uint32_t, and folly::test::DeterministicSchedule::uniform().

476  {
477  DeterministicSchedule sched(DeterministicSchedule::uniform(FLAGS_seed));
478 
479  unsigned size = 2;
480  unsigned iters = size * 64 * 4;
482  unsigned long,
483  unsigned long,
484  std::hash<unsigned long>,
485  std::equal_to<unsigned long>,
486  std::allocator<uint8_t>,
487  8,
488  Atom,
489  Mutex>
490  m(2);
491 
492  EXPECT_TRUE(m.insert(0, 0).second);
493  EXPECT_FALSE(m.insert(0, 0).second);
494  std::vector<std::thread> threads;
495  unsigned int num_threads = 32;
496  for (uint32_t t = 0; t < num_threads; t++) {
497  threads.push_back(lib::thread([&, t]() {
498  int offset = (iters * t / num_threads);
499  for (uint32_t i = 0; i < iters / num_threads; i++) {
500  auto var = offset + i + 1;
501  EXPECT_TRUE(m.insert(var, var).second);
502  EXPECT_FALSE(m.insert(0, 0).second);
503  }
504  }));
505  }
506  for (auto& t : threads) {
507  join;
508  }
509 }
#define Mutex
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define Atom
static map< string, int > m
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define join
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ConcurrentHashMap  ,
assignStressTest   
)

Definition at line 511 of file ConcurrentHashMapTest.cpp.

References a, Atom, b, check(), EXPECT_EQ, EXPECT_NE, i, folly::join(), m, Mutex, folly::size(), folly::pushmi::detail::t, threads, uint32_t, uint64_t, folly::test::DeterministicSchedule::uniform(), and v.

511  {
512  DeterministicSchedule sched(DeterministicSchedule::uniform(FLAGS_seed));
513 
514  unsigned size = 2;
515  unsigned iters = size * 64 * 4;
516  struct big_value {
517  uint64_t v1;
518  uint64_t v2;
519  uint64_t v3;
520  uint64_t v4;
521  uint64_t v5;
522  uint64_t v6;
523  uint64_t v7;
524  uint64_t v8;
525  void set(uint64_t v) {
526  v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v;
527  }
528  void check() const {
529  auto v = v1;
530  EXPECT_EQ(v, v8);
531  EXPECT_EQ(v, v7);
532  EXPECT_EQ(v, v6);
533  EXPECT_EQ(v, v5);
534  EXPECT_EQ(v, v4);
535  EXPECT_EQ(v, v3);
536  EXPECT_EQ(v, v2);
537  }
538  };
540  unsigned long,
541  big_value,
542  std::hash<unsigned long>,
543  std::equal_to<unsigned long>,
544  std::allocator<uint8_t>,
545  8,
546  Atom,
547  Mutex>
548  m(2);
549 
550  for (uint32_t i = 0; i < iters; i++) {
551  big_value a;
552  a.set(i);
553  m.insert(i, a);
554  }
555 
556  std::vector<std::thread> threads;
557  unsigned int num_threads = 32;
558  for (uint32_t t = 0; t < num_threads; t++) {
559  threads.push_back(lib::thread([&]() {
560  for (uint32_t i = 0; i < iters; i++) {
561  auto res = m.find(i);
562  EXPECT_NE(res, m.cend());
563  res->second.check();
564  big_value b;
565  b.set(res->second.v1 + 1);
566  m.assign(i, b);
567  }
568  }));
569  }
570  for (auto& t : threads) {
571  join;
572  }
573 }
auto v
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define Mutex
std::vector< std::thread::id > threads
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
#define Atom
static map< string, int > m
char a
#define join
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
bool check(const dynamic &schema, const dynamic &value, bool check=true)
TEST ( ConcurrentHashMap  ,
RefcountTest   
)

Definition at line 575 of file ConcurrentHashMapTest.cpp.

References i, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert_or_assign(), int32_t, and uint64_t.

575  {
576  struct badhash {
577  size_t operator()(uint64_t) const {
578  return 0;
579  }
580  };
582  uint64_t,
583  uint64_t,
584  badhash,
585  std::equal_to<uint64_t>,
586  std::allocator<uint8_t>,
587  0>
588  foomap(3);
589  foomap.insert(0, 0);
590  foomap.insert(1, 1);
591  foomap.insert(2, 2);
592  for (int32_t i = 0; i < 300; ++i) {
593  foomap.insert_or_assign(1, i);
594  }
595 }
TEST ( ConcurrentHashMap  ,
Deletion   
)

Definition at line 606 of file ConcurrentHashMapTest.cpp.

References EXPECT_TRUE, folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

606  {
607  bool del{false};
608 
609  {
611 
612  map.insert(0, std::make_shared<Wrapper>(del));
613  }
614 
616 
617  EXPECT_TRUE(del);
618 }
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
DeletionWithErase   
)

Definition at line 620 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::erase(), EXPECT_TRUE, folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

620  {
621  bool del{false};
622 
623  {
625 
626  map.insert(0, std::make_shared<Wrapper>(del));
627  map.erase(0);
628  }
629 
631 
632  EXPECT_TRUE(del);
633 }
size_type erase(const key_type &k)
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
DeletionWithIterator   
)

Definition at line 635 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::erase(), EXPECT_TRUE, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::find(), folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

635  {
636  bool del{false};
637 
638  {
640 
641  map.insert(0, std::make_shared<Wrapper>(del));
642  auto it = map.find(0);
643  map.erase(it);
644  }
645 
647 
648  EXPECT_TRUE(del);
649 }
size_type erase(const key_type &k)
ConstIterator find(const KeyType &k) const
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
DeletionWithForLoop   
)

Definition at line 651 of file ConcurrentHashMapTest.cpp.

References folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cbegin(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::cend(), EXPECT_EQ, EXPECT_TRUE, folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

651  {
652  bool del{false};
653 
654  {
656 
657  map.insert(0, std::make_shared<Wrapper>(del));
658  for (auto it = map.cbegin(); it != map.cend(); ++it) {
659  EXPECT_EQ(it->first, 0);
660  }
661  }
662 
664 
665  EXPECT_TRUE(del);
666 }
ConstIterator cbegin() const noexcept
ConstIterator cend() const noexcept
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
DeletionMultiple   
)

Definition at line 668 of file ConcurrentHashMapTest.cpp.

References EXPECT_TRUE, folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

668  {
669  bool del1{false}, del2{false};
670 
671  {
673 
674  map.insert(0, std::make_shared<Wrapper>(del1));
675  map.insert(1, std::make_shared<Wrapper>(del2));
676  }
677 
679 
680  EXPECT_TRUE(del1);
681  EXPECT_TRUE(del2);
682 }
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
DeletionAssigned   
)

Definition at line 684 of file ConcurrentHashMapTest.cpp.

References EXPECT_TRUE, folly::hazptr_cleanup(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert_or_assign(), and map().

684  {
685  bool del1{false}, del2{false};
686 
687  {
689 
690  map.insert(0, std::make_shared<Wrapper>(del1));
691  map.insert_or_assign(0, std::make_shared<Wrapper>(del2));
692  }
693 
695 
696  EXPECT_TRUE(del1);
697  EXPECT_TRUE(del2);
698 }
static Map map(mapCap)
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::pair< ConstIterator, bool > insert_or_assign(Key &&k, Value &&v)
TEST ( ConcurrentHashMap  ,
DeletionMultipleMaps   
)

Definition at line 700 of file ConcurrentHashMapTest.cpp.

References EXPECT_TRUE, folly::hazptr_cleanup(), and folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert().

700  {
701  bool del1{false}, del2{false};
702 
703  {
706 
707  map1.insert(0, std::make_shared<Wrapper>(del1));
708  map2.insert(0, std::make_shared<Wrapper>(del2));
709  }
710 
712 
713  EXPECT_TRUE(del1);
714  EXPECT_TRUE(del2);
715 }
void hazptr_cleanup(hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >()) noexcept
Definition: HazptrDomain.h:384
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ConcurrentHashMap  ,
ForEachLoop   
)

Definition at line 717 of file ConcurrentHashMapTest.cpp.

References EXPECT_EQ, folly::ConcurrentHashMap< KeyType, ValueType, HashFn, KeyEqual, Allocator, ShardBits, Atom, Mutex >::insert(), and map().

717  {
719  map.insert(1, 2);
720  size_t iters = 0;
721  for (const auto& kv : map) {
722  EXPECT_EQ(kv.first, 1);
723  EXPECT_EQ(kv.second, 2);
724  ++iters;
725  }
726  EXPECT_EQ(iters, 1);
727 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static Map map(mapCap)
std::pair< ConstIterator, bool > insert(std::pair< key_type, mapped_type > &&foo)
TEST ( ConcurrentHashMap  ,
IteratorMove   
)

Definition at line 729 of file ConcurrentHashMapTest.cpp.

References ASSERT_EQ, folly::foo, foo2(), gen_gtest_pred_impl::Iter(), k, map(), and folly::gen::move.

729  {
730  using CHM = ConcurrentHashMap<int, int>;
731  using Iter = CHM::ConstIterator;
732  struct Foo {
733  Iter it;
734  explicit Foo(Iter&& it_) : it(std::move(it_)) {}
735  Foo(Foo&&) = default;
736  Foo& operator=(Foo&&) = default;
737  };
738  CHM map;
739  int k = 111;
740  int v = 999999;
741  map.insert(k, v);
742  Foo foo(map.find(k));
743  ASSERT_EQ(foo.it->second, v);
744  Foo foo2(map.find(0));
745  foo2 = std::move(foo);
746  ASSERT_EQ(foo2.it->second, v);
747 }
Foo(std::atomic< int > &d)
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
FOLLY_NOINLINE void foo2()
def Iter(n, format, sep='')
static Map map(mapCap)
KeyT k