SpiecsEngine
 
Loading...
Searching...
No Matches

◆ FetchRange()

size_t Spices::CentralCache::FetchRange ( void *& start,
void *& end,
size_t batchNum,
size_t size )

Fetch range memory to tc.

Parameters
[in,out]startmemory start block pointer.
[in,out]endmemory end block pointer.
[in]batchNumblock count.
[in]sizealigned bytes.
Returns
Returns actual block count.

fetch spare memory.

fetch spare memory.

Definition at line 15 of file CentralCache.cpp.

16 {
17 const size_t index = MemoryPool::Index(size);
18 size_t actualNum = 1;
19
20 {
21 std::unique_lock<std::mutex> lock(m_SpanLists[index].GetMutex());
22
23 scl::span* s = GetOneSpan(m_SpanLists[index], size);
24 assert(s);
25 assert(s->m_FreeList);
26
27 start = end = s->m_FreeList;
28
32 size_t i = 0;
33 while (i < batchNum - 1 && MemoryPool::PointerSpace(end) != nullptr)
34 {
35 end = MemoryPool::PointerSpace(end);
36 ++actualNum;
37 ++i;
38 }
39
41 s->m_UseCount += actualNum;
42 MemoryPool::PointerSpace(end) = nullptr;
43 }
44
45 return actualNum;
46 }
static scl::span * GetOneSpan(scl::span_list &list, size_t size)
Get a not empty span.
std::array< scl::span_list, MemoryPool::FREE_LIST_NUM > m_SpanLists
FreeList Array.
static size_t Index(size_t size)
Determine which freelist should process the memory block with given bytes.
static void *& PointerSpace(void *obj)
Get object first 4/8 bytes as a pointer.
void * m_FreeList
current pointer.
Definition SpanList.h:51
size_t m_UseCount
In used memory block count.
Definition SpanList.h:56
Used for manage multiple page memory.
Definition SpanList.h:15

References scl::span::m_FreeList, and Spices::MemoryPool::PointerSpace().