SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Alloc()

void * Spices::MemoryPool::Alloc ( size_t size)
static

Alloc memory entry point.

Parameters
[in]sizememory bytes.
Returns
Returns memory pointer.

allocate from pc.

allocate from tc.

allocate from pc.

allocate from tc.

Definition at line 15 of file MemoryPool.cpp.

16 {
20 if (size > MAX_BYTES)
21 {
22 const size_t alignSize = AlignUp(size);
23 size_t k = alignSize >> PAGE_SHIFT;
24
26 s->m_IsUse = true;
27 s->m_BlockSize = alignSize;
28
29 void* ptr = reinterpret_cast<void*>(s->m_PageId << PAGE_SHIFT);
30 return ptr;
31 }
32
36 else
37 {
39 }
40 }
static constexpr size_t MAX_BYTES
Only allowed 256KB allocated memory one time in tc.
Definition MemoryPool.h:34
static size_t AlignUp(size_t size)
Align up memory bytes.
static constexpr size_t PAGE_SHIFT
8KB in a page.
Definition MemoryPool.h:44
static PageCache * Get()
Get this single instance.
Definition PageCache.h:50
scl::span * NewSpan(size_t k)
Fetch pages span.
Definition PageCache.cpp:14
static ThreadCache *& GetInst()
Get ThreadCache Instance. @reutrn Returns ThreadCache Instance.
void * Allocate(size_t size)
Allocate memory.
size_t m_BlockSize
page block size.
Definition SpanList.h:66
size_t m_PageId
Start page id.
Definition SpanList.h:31
bool m_IsUse
True if in use.
Definition SpanList.h:61
Used for manage multiple page memory.
Definition SpanList.h:15

References scl::span::m_IsUse.