SpiecsEngine
 
Loading...
Searching...
No Matches

◆ ReleaseListToSpans()

void Spices::CentralCache::ReleaseListToSpans ( void * start,
size_t size )

Release memory to pc.

Parameters
[in]startmemory start pointer.
[in]sizealigned bytes.

Iter all blocks and insert to span.

Find span.

Insert from head to span.

if span is not in use, than release to pc.

unlock span mutex.

release to pc.

get span mutex.

Iter all blocks and insert to span.

Find span.

Insert from head to span.

if span is not in use, than release to pc.

unlock span mutex.

release to pc.

get span mutex.

Definition at line 122 of file CentralCache.cpp.

123 {
124 const size_t index = MemoryPool::Index(size);
125
126 {
127 std::unique_lock<std::mutex> lock(m_SpanLists[index].GetMutex());
128
132 while (start)
133 {
134 void* next = MemoryPool::PointerSpace(start);
135
140
145 s->m_FreeList = start;
146 s->m_UseCount--;
147
151 if (s->m_UseCount == 0)
152 {
153 m_SpanLists[index].Erase(s);
154 s->m_FreeList = nullptr;
155
159 m_SpanLists[index].GetMutex().unlock();
160
165
169 m_SpanLists[index].GetMutex().lock();
170 }
171
172 start = next;
173 }
174 }
175 }
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.
scl::span * MapObjectToSpan(void *obj) const
Find span by memory pointer.
Definition PageCache.cpp:21
static PageCache * Get()
Get this single instance.
Definition PageCache.h:50
void ReleaseSpanToPageCache(scl::span *s)
Release span from cc to pc,.
Definition PageCache.cpp:43
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 Spices::PageCache::Get(), scl::span::m_FreeList, Spices::PageCache::MapObjectToSpan(), Spices::MemoryPool::PointerSpace(), and Spices::PageCache::ReleaseSpanToPageCache().