X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FAtomicHashMap.h;h=70d71491a4499231f3de70377da3bf31088645a1;hb=16f34c7d5024564897bd4ab6ca9b6725747c2ea6;hp=53c8d8afba84f94b962bd07b06155d536b60a06a;hpb=321542683a01c3f334047531e9b487f047129775;p=folly.git diff --git a/folly/AtomicHashMap.h b/folly/AtomicHashMap.h index 53c8d8af..70d71491 100644 --- a/folly/AtomicHashMap.h +++ b/folly/AtomicHashMap.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /* * AtomicHashMap -- * - * A high performance concurrent hash map with int32 or int64 keys. Supports + * A high-performance concurrent hash map with int32 or int64 keys. Supports * insert, find(key), findAt(index), erase(key), size, and more. Memory cannot * be freed or reclaimed by erase. Can grow to a maximum of about 18 times the * initial capacity, but performance degrades linearly with growth. Can also be @@ -25,7 +25,7 @@ * internal storage (retrieved with iterator::getIndex()). * * Advantages: - * - High performance (~2-4x tbb::concurrent_hash_map in heavily + * - High-performance (~2-4x tbb::concurrent_hash_map in heavily * multi-threaded environments). * - Efficient memory usage if initial capacity is not over estimated * (especially for small keys and values). @@ -56,7 +56,7 @@ * faster because of reduced data indirection. * * AHMap is a wrapper around AHArray sub-maps that allows growth and provides - * an interface closer to the stl UnorderedAssociativeContainer concept. These + * an interface closer to the STL UnorderedAssociativeContainer concept. These * sub-maps are allocated on the fly and are processed in series, so the more * there are (from growing past initial capacity), the worse the performance. * @@ -79,7 +79,7 @@ * */ -#ifndef FOLLY_ATOMICHASHMAP_H_ +#pragma once #define FOLLY_ATOMICHASHMAP_H_ #include @@ -197,7 +197,8 @@ typedef AtomicHashArray subMaps_[kNumSubMaps_]; std::atomic numMapsAllocated_; - inline bool tryLockMap(int idx) { + inline bool tryLockMap(unsigned int idx) { SubMap* val = nullptr; return subMaps_[idx].compare_exchange_strong(val, (SubMap*)kLockedPtr_, std::memory_order_acquire); @@ -472,5 +473,3 @@ using QuadraticProbingAtomicHashMap = } // namespace folly #include - -#endif // FOLLY_ATOMICHASHMAP_H_