MemoryPool
developer-kikikaikai edited this page Jul 21, 2018
·
8 revisions
Here, only show simply explain what is it. Base of this page is How to use library? and When it can help you?.
And this library contains my preference, and maybe custom pattern for my preference a little.
Simply definition in here:
- By using this, user can get allocated memory smoothly. This allocated memory is managed in this.
- It can use like a prototype to use constructor.
Store list of allocated data, which size modify modified to 2^x bit size. like following:
And memory instances update by using input constructor if you want.
When get memory:
When release memory:
Only MemoryPool class which has allocated memory list as above.
Please see Doxygen. Raw code is here
- to call
mpool_create
, CreateMemoryPool
instance (has list of allocate memory pointer initialize byconstructor
) -
mpool_get
to get allocated memory. -
mpool_release
to release allocated memory (this means not free, only unset used flag) - If you want to do all used memory loop, please use
FOR_ALL_USEDMEM
macro.
Please see test code.
Support Linux
I check:
- Ubuntu(18.04 Desktop)
- Cent OS(7.5.1804)
- Builder
- Singleton (contained in Flyweight)
- Flyweight
- Chain of Responsibility
- Observer(Publish-Subscribe)
- State (and StateMachine)
- Prototype
- Memento
- Threadpool (with FD)
Now I don't write wiki, only add link of Japanese website Qiita.
- Abstract Factory
- Factory Method
- Adapter
- Bridge
- Decorator
- Facade
- Proxy
- Command
- Mediator
- Strategy
- Template Method
- Visitor
- Composite
- Interpreter
- Iterator