]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/third-party/folly/folly/synchronization/ParkingLot.cpp
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
6 #include <folly/synchronization/ParkingLot.h>
11 namespace parking_lot_detail
{
13 Bucket
& Bucket::bucketFor(uint64_t key
) {
14 constexpr size_t const kNumBuckets
= 4096;
16 // Statically allocating this lets us use this in allocation-sensitive
17 // contexts. This relies on the assumption that std::mutex won't dynamically
18 // allocate memory, which we assume to be the case on Linux and iOS.
19 static Indestructible
<std::array
<Bucket
, kNumBuckets
>> gBuckets
;
20 return (*gBuckets
)[key
% kNumBuckets
];
23 std::atomic
<uint64_t> idallocator
{0};
25 } // namespace parking_lot_detail