SpiecsEngine
 
Loading...
Searching...
No Matches
CentralCache.h
Go to the documentation of this file.
1/**
2* @file CentralCache.cpp.
3* @brief The CentralCache Class Definitions.
4* @author tcmalloc.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "MemoryPool.h"
10#include "Core/Container/SpanList.h"
11
12namespace Spices {
13
14 /**
15 * @brief Central memory cache.
16 * Second level of memory allocator.
17 */
19 {
20 public:
21
22 /**
23 * @brief Constructor Function.
24 */
25 CentralCache() = default;
26
27 /**
28 * @brief Destructor Function.
29 */
30 virtual ~CentralCache() = default;
31
32 /**
33 * @brief Copy Constructor Function.
34 * @note This Class not allowed copy behaves.
35 */
36 CentralCache(const CentralCache&) = delete;
37
38 /**
39 * @brief Copy Assignment Operation.
40 * @note This Class not allowed copy behaves.
41 */
42 CentralCache& operator =(const CentralCache&) = delete;
43
44 /**
45 * @brief Get this single Instance.
46 * @return Returns this pointer.
47 */
48 static CentralCache* Get() { return &m_CentralCache; }
49
50 /**
51 * @brief Fetch range memory to tc.
52 * @param[in,out] start memory start block pointer.
53 * @param[in,out] end memory end block pointer.
54 * @param[in] batchNum block count.
55 * @param[in] size aligned bytes.
56 * @return Returns actual block count.
57 */
59
60 /**
61 * @brief Release memory to pc.
62 * @param[in] start memory start pointer.
63 * @param[in] size aligned bytes.
64 */
65 void ReleaseListToSpans(void* start, size_t size);
66
67 private:
68
69 /**
70 * @brief Get a not empty span.
71 * @param[in,out] list span list.
72 * @param[in] size aligned bytes.
73 * @return Returns span.
74 */
75 static scl::span* GetOneSpan(scl::span_list& list, size_t size);
76
77 private:
78
79 /**
80 * @brief FreeList Array.
81 */
83
84 /**
85 * @brief Single instance of this.
86 */
88 };
89}
CentralCache()=default
Constructor Function.
static scl::span * GetOneSpan(scl::span_list &list, size_t size)
Get a not empty span.
size_t FetchRange(void *&start, void *&end, size_t batchNum, size_t size)
Fetch range memory to tc.
static CentralCache m_CentralCache
Single instance of this.
CentralCache & operator=(const CentralCache &)=delete
Copy Assignment Operation.
virtual ~CentralCache()=default
Destructor Function.
void ReleaseListToSpans(void *start, size_t size)
Release memory to pc.
std::array< scl::span_list, MemoryPool::FREE_LIST_NUM > m_SpanLists
FreeList Array.
CentralCache(const CentralCache &)=delete
Copy Constructor Function.
static CentralCache * Get()
Get this single Instance.
Central memory cache. Second level of memory allocator.
static void *& PointerSpace(void *obj)
Get object first 4/8 bytes as a pointer.
MemoryPool Class.
Definition MemoryPool.h:22
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
Page memory cache. Third level of memory allocator.
Definition PageCache.h:21
void PushFront(span *s)
Push a span to this list.
Definition SpanList.cpp:40
span * Begin() const
Get begin pointer.
Definition SpanList.cpp:59
span * End() const
Get end pointer.
Definition SpanList.cpp:64
Bidirectional cyclic linked list for span.
Definition SpanList.h:73
span * m_Next
next span.
Definition SpanList.h:41
void * m_FreeList
current pointer.
Definition SpanList.h:51
bool m_IsUse
True if in use.
Definition SpanList.h:61
Used for manage multiple page memory.
Definition SpanList.h:15