Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/backend/gporca/libgpos/include/gpos/memory/CMemoryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#ifndef GPOS_CMemoryPool_H
#define GPOS_CMemoryPool_H

#include <limits>
#include <random>

#include "gpos/assert.h"
#include "gpos/common/CLink.h"
#include "gpos/common/CStackDescriptor.h"
Expand Down Expand Up @@ -75,7 +78,11 @@ class CMemoryPool
friend class CMemoryPoolManager;

private:
// hash key is only set by pool manager
// psudo random hash key generator
std::mt19937 m_generator;
std::uniform_int_distribution<ULONG> m_distribution;

// hash key for this memory pool
ULONG_PTR m_hash_key;

#ifdef GPOS_DEBUG
Expand All @@ -98,6 +105,13 @@ class CMemoryPool
EatArray = 0x7e
};

CMemoryPool()
// MAX LONG is invalid hash key, so skip that hash value.
: m_distribution(0, std::numeric_limits<ULONG>::max() - 1),
m_hash_key(m_distribution(m_generator))
{
}

// dtor
virtual ~CMemoryPool() = default;

Expand Down