folly::Init, RAII variant of folly::init
[folly.git] / folly / test / AtomicUnorderedMapTest.cpp
index 957b6063330dfb102e09cfdaa98c2004486e4edc..9d1287db120c1004f1110e6347aad6064b7cae08 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <folly/AtomicUnorderedMap.h>
 
+#include <memory>
 #include <thread>
 #include <unordered_map>
 
@@ -28,7 +29,7 @@
 using namespace folly;
 using namespace folly::test;
 
-template<class T>
+template <class T>
 struct non_atomic {
   T value;
 
@@ -88,11 +89,12 @@ struct non_atomic {
   bool is_lock_free() const {return true;}
 };
 
-template <typename Key,
-          typename Value,
-          typename IndexType,
-          template <typename> class Atom = std::atomic,
-          typename Allocator = std::allocator<char>>
+template <
+    typename Key,
+    typename Value,
+    typename IndexType,
+    template <typename> class Atom = std::atomic,
+    typename Allocator = std::allocator<char>>
 using UIM =
     AtomicUnorderedInsertMap<Key,
                              Value,
@@ -107,7 +109,7 @@ using UIM =
 namespace {
 template <typename T>
 struct AtomicUnorderedInsertMapTest : public ::testing::Test {};
-}
+} // namespace
 
 // uint16_t doesn't make sense for most platforms, but we might as well
 // test it
@@ -206,7 +208,7 @@ BENCHMARK(lookup_int_int_hit, iters) {
   size_t capacity = 100000;
 
   BENCHMARK_SUSPEND {
-    ptr.reset(new AtomicUnorderedInsertMap<int,size_t>(capacity));
+    ptr = std::make_unique<AtomicUnorderedInsertMap<int, size_t>>(capacity);
     for (size_t i = 0; i < capacity; ++i) {
       auto k = 3 * ((5641 * i) % capacity);
       ptr->emplace(k, k + 1);
@@ -248,7 +250,7 @@ void contendedRW(size_t itersPerThread,
   std::vector<std::thread> threads;
 
   BENCHMARK_SUSPEND {
-    ptr.reset(new Map(capacity));
+    ptr = std::make_unique<Map>(capacity);
     while (threads.size() < numThreads) {
       threads.emplace_back([&](){
         while (!go) {