|
MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
Public 类型 | |
| using | item_unique_ptr = unique_ptr< void, function< void(void *const)> > |
Public 成员函数 | |
| MemPoolItem (const char *tag) | |
| int | init (int item_size, bool dynamic=true, int pool_num=DEFAULT_POOL_NUM, int item_num_per_pool=DEFAULT_ITEM_NUM_PER_POOL) |
| void | cleanup () |
| int | extend () |
| void * | alloc () |
| item_unique_ptr | alloc_unique_ptr () |
| void | free (void *item) |
| bool | is_used (void *item) |
| string | to_string () |
| const string | get_name () const |
| bool | is_dynamic () const |
| int | get_size () const |
| int | get_item_size () const |
| int | get_item_num_per_pool () const |
| int | get_used_num () |
Protected 属性 | |
| pthread_mutex_t | mutex |
| string | name |
| bool | dynamic |
| int | size |
| int | item_size |
| int | item_num_per_pool |
| list< void * > | pools |
| set< void * > | used |
| list< void * > | frees |
| void * common::MemPoolItem::alloc | ( | ) |
Alloc one frame from memory Pool
| void common::MemPoolItem::cleanup | ( | ) |
Do cleanup job for memory pool
| int common::MemPoolItem::extend | ( | ) |
If dynamic has been set, extend current memory pool,
| void common::MemPoolItem::free | ( | void * | item | ) |
Free one item, the resouce will return to memory Pool
| item |
| int common::MemPoolItem::init | ( | int | item_size, |
| bool | dynamic = true, |
||
| int | pool_num = DEFAULT_POOL_NUM, |
||
| int | item_num_per_pool = DEFAULT_ITEM_NUM_PER_POOL |
||
| ) |
init memory pool, the major job is to alloc memory for memory pool
| pool_num,memory | pool's number |
| item_num_per_pool,how | many items per pool. |
|
inline |
Check whether this item has been used before.
| item |