-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemoryPoolManager.hpp
106 lines (71 loc) · 1.72 KB
/
MemoryPoolManager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _MEMORYPOOLMANAGER_HPP_
#define _MEMORYPOOLMANAGER_HPP_
/*
Name
MemoryPoolManager
Authors
[ETL] Eun T. Leem ([email protected])
Description
Last Modified Date
February 27, 2014
History
February 27, 2014
Created
ToDos
Milestones
1.0
Learning Resources
http://
Copyright (c) All rights reserved to LIFEINO.
*/
#ifdef _DEBUG
#undef _DEBUG
#endif
#define _DEBUG true
//#include "Debug.hpp"
#include "liolib/Debug.hpp"
#include "liolib/MemoryPool.hpp"
#include <string> // std::string
#include <vector> // std::vector
namespace lio {
using std::vector;
using std::string;
class MemoryPoolManager {
public:
// ******** Exception Declaration *********
enum class ExceptionType : std::uint8_t {
GENERAL
};
#define MEMORYPOOLMANAGER_EXCEPTION_MESSAGES \
"MemoryPoolManager Exception has been thrown."
class Exception : public std::exception {
public:
Exception (ExceptionType exceptionType = ExceptionType::GENERAL);
virtual const char* what() const noexcept;
virtual const ExceptionType type() const noexcept;
private:
const ExceptionType exceptionType_;
static const char* const exceptionMessages_[];
};
// ******** Exception Declaration END*********
struct Config {
Config()
: numPoolMax(4),
poolSizeMax(1024 * 1024 * 4) // 4MB
{ }
int numPoolMax;
int poolSizeMax;
MemoryPool::Config defaultMpConfig;
};
MemoryPoolManager(Config& config);
~MemoryPoolManager();
void* const Mpalloc(size_t allocSize);
size_t Mpfree (const void* freePtr);
protected:
private:
Config config_;
vector<MemoryPool*> poolList_;
void addPool (MemoryPool::Config& poolConfig);
};
}
#endif