SpiecsEngine
 
Loading...
Searching...
No Matches

◆ FetchFromCentralCache()

void * Spices::ThreadCache::FetchFromCentralCache ( size_t index,
size_t alignSize )
private

Fetch memory from central cache if this is run out.

Parameters
[in]indexfreelist index.
[in]alignSizealign up bytes.
Returns
Returns memory pointer.

Slow-Start Threshold Dynamic Adjustment Algorithm.

Obtain actural blocks form cc.

push other blocks to freelist if obtained more than one block.

Slow-Start Threshold Dynamic Adjustment Algorithm.

Obtain actural blocks form cc.

push other blocks to freelist if obtained more than one block.

Definition at line 78 of file ThrealCache.cpp.

79 {
83 const size_t batchNum = std::min(m_FreeLists[index].ApplyforNBlocks(), MemoryPool::GetNBlocksLimit(alignSize));
84
85 if (batchNum == m_FreeLists[index].ApplyforNBlocks())
86 {
87 m_FreeLists[index].IncreaseInNextApplyFor();
88 }
89
90 void* start = nullptr;
91 void* end = nullptr;
92
96 const size_t actualNum = CentralCache::Get()->FetchRange(start, end, batchNum, alignSize);
97
98 assert(actualNum >= 1);
99
103 if (actualNum > 1)
104 {
105 m_FreeLists[index].PushRange(MemoryPool::PointerSpace(start), end, actualNum - 1);
106 }
107
108 return start;
109 }
size_t FetchRange(void *&start, void *&end, size_t batchNum, size_t size)
Fetch range memory to tc.
static CentralCache * Get()
Get this single Instance.
static size_t GetNBlocksLimit(size_t size)
Get count of blocks limit by tc align up bytes.
static void *& PointerSpace(void *obj)
Get object first 4/8 bytes as a pointer.
std::array< scl::free_list, MemoryPool::FREE_LIST_NUM > m_FreeLists
FreeList Array.
Definition ThrealCache.h:81