38 if (mWriteOffset.load(memory_order_relaxed) >= mObjectStoreSizeBytes)
53 begin = min(begin, mObjectStoreSizeBytes);
65 JPH_ASSERT(data >= mObjectStore && data < mObjectStore + mObjectStoreSizeBytes);
66 return uint32(data - mObjectStore);
73 return reinterpret_cast<T *
>(mObjectStore +
inOffset);
97 mAllocator.
Allocate(mBlockSize, mBegin, mEnd);
118template <
class Key,
class Value>
132template <
class Key,
class Value>
138template <
class Key,
class Value>
141#ifdef JPH_ENABLE_ASSERTS
147 static_assert(
sizeof(atomic<uint32>) ==
sizeof(
uint32));
159template <
class Key,
class Value>
169template <
class Key,
class Value>
184#ifdef JPH_ENABLE_ASSERTS
213template <
class Key,
class Value>
218 while (
offset != cInvalidHandle)
231template <
class Key,
class Value>
237template <
class Key,
class Value>
243template <
class Key,
class Value>
246 for (
const atomic<uint32> *
bucket = mBuckets;
bucket < mBuckets + mNumBuckets; ++
bucket)
249 while (
offset != cInvalidHandle)
258template <
class Key,
class Value>
265 if (
it.mOffset == cInvalidHandle)
271template <
class Key,
class Value>
274 return {
this, mNumBuckets, cInvalidHandle };
277template <
class Key,
class Value>
285template <
class Key,
class Value>
294 mOffset =
kv->mNextOffset;
304 if (mBucket >= mMap->mNumBuckets)
308 mOffset = mMap->mBuckets[mBucket];
316template <
class Key,
class Value>
std::uint8_t uint8
Definition Core.h:440
std::uint64_t uint64
Definition Core.h:443
unsigned int uint
Definition Core.h:439
#define JPH_NAMESPACE_END
Definition Core.h:367
std::uint32_t uint32
Definition Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
TraceFunction Trace
Definition IssueReporting.cpp:18
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
constexpr bool IsPowerOf2(T inV)
Check if inV is a power of 2.
Definition Math.h:73
bool IsAligned(T inV, uint64 inAlignment)
Check if inV is inAlignment aligned.
Definition Math.h:88
AllocateFunction Allocate
Definition Memory.cpp:59
AlignedFreeFunction AlignedFree
Definition Memory.cpp:62
AlignedAllocateFunction AlignedAllocate
Definition Memory.cpp:61
std::vector< T, STLAllocator< T > > Array
Definition STLAllocator.h:81
Definition LockFreeHashMap.h:49
LFHMAllocatorContext(LFHMAllocator &inAllocator, uint32 inBlockSize)
Construct a new allocator context.
Definition LockFreeHashMap.inl:80
bool Allocate(uint32 inSize, uint32 inAlignment, uint32 &outWriteOffset)
Allocate data block.
Definition LockFreeHashMap.inl:86
Allocator for a lock free hash map.
Definition LockFreeHashMap.h:14
uint32 ToOffset(const T *inData) const
Convert a pointer to an offset.
Definition LockFreeHashMap.inl:62
~LFHMAllocator()
Destructor.
Definition LockFreeHashMap.inl:13
void Init(uint inObjectStoreSizeBytes)
Definition LockFreeHashMap.inl:18
T * FromOffset(uint32 inOffset) const
Convert an offset to a pointer.
Definition LockFreeHashMap.inl:70
void Allocate(uint32 inBlockSize, uint32 &ioBegin, uint32 &ioEnd)
Definition LockFreeHashMap.inl:31
void Clear()
Clear all allocations.
Definition LockFreeHashMap.inl:26
A key / value pair that is inserted in the map.
Definition LockFreeHashMap.h:100
Definition LockFreeHashMap.h:72
const KeyValue * FromHandle(uint32 inHandle) const
Convert uint32 handle back to key and value.
Definition LockFreeHashMap.inl:238
Iterator begin()
Definition LockFreeHashMap.inl:259
void GetAllKeyValues(Array< const KeyValue * > &outAll) const
Get all key/value pairs.
Definition LockFreeHashMap.inl:244
void Init(uint32 inMaxBuckets)
Definition LockFreeHashMap.inl:119
void SetNumBuckets(uint32 inNumBuckets)
Definition LockFreeHashMap.inl:160
KeyValue * Create(LFHMAllocatorContext &ioContext, const Key &inKey, uint64 inKeyHash, int inExtraBytes, Params &&... inConstructorParams)
Definition LockFreeHashMap.inl:171
~LockFreeHashMap()
Definition LockFreeHashMap.inl:133
const KeyValue * Find(const Key &inKey, uint64 inKeyHash) const
Find an element, returns null if not found.
Definition LockFreeHashMap.inl:214
uint32 ToHandle(const KeyValue *inKeyValue) const
Get convert key value pair to uint32 handle.
Definition LockFreeHashMap.inl:232
Iterator end()
Definition LockFreeHashMap.inl:272
static const uint32 cInvalidHandle
Value of an invalid handle.
Definition LockFreeHashMap.h:123
void Clear()
Definition LockFreeHashMap.inl:139
static JPH_INLINE UVec4 sReplicate(uint32 inV)
Replicate int inV across all components.
Definition UVec4.inl:56
Non-const iterator.
Definition LockFreeHashMap.h:142
uint32 mOffset
Definition LockFreeHashMap.h:155
Iterator & operator++()
Next item.
Definition LockFreeHashMap.inl:286
MapType * mMap
Definition LockFreeHashMap.h:153
KeyValue & operator*()
Convert to key value pair.
Definition LockFreeHashMap.inl:278