mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 10:57:34 +08:00
add dbuf_reset in class dbuf_pool for performance improvement
This commit is contained in:
parent
26ede3c85a
commit
1156716a32
@ -1,6 +1,12 @@
|
||||
修改历史列表:
|
||||
|
||||
------------------------------------------------------------------------
|
||||
317) 2015.6.22
|
||||
317.1) feature: dbuf_pool 类增加了 dbuf_reset 方法,可以重复使用该类对象
|
||||
317.2) performance: redis_command 类当每一个命令处理完毕后不再释放内存池对象,
|
||||
而是复用之
|
||||
317.3) bugfix: redis_zset 类有一处在调用 sizeof 时未 -1
|
||||
|
||||
316) 2015.6.17
|
||||
316.1) feature: 增加了类 thread_queue 用来处理线程消息队列
|
||||
|
||||
|
@ -17,6 +17,11 @@ public:
|
||||
dbuf_pool(size_t block_size = 8192);
|
||||
~dbuf_pool();
|
||||
|
||||
/**
|
||||
* 重置内存池的状态以便于重复使用该内存池对象
|
||||
*/
|
||||
void dbuf_reset();
|
||||
|
||||
/**
|
||||
* 分配指定长度的内存
|
||||
* @param len {size_t} 需要分配的内存长度,当内存比较小时(小于构造函数中的
|
||||
|
@ -113,8 +113,7 @@ void redis_command::clear(bool save_slot /* = false */)
|
||||
{
|
||||
if (used_ > 0)
|
||||
{
|
||||
delete pool_;
|
||||
pool_ = NEW dbuf_pool();
|
||||
pool_->dbuf_reset();
|
||||
result_ = NULL;
|
||||
}
|
||||
if (!save_slot)
|
||||
|
@ -1010,7 +1010,7 @@ int redis_zset::zrangebylex(const char* key, const char* min, const char* max,
|
||||
size_t argc = 4;
|
||||
|
||||
argv[0] = "ZRANGEBYLEX";
|
||||
lens[0] = sizeof("ZRANGEBYLEX");
|
||||
lens[0] = sizeof("ZRANGEBYLEX") - 1;
|
||||
|
||||
argv[1] = key;
|
||||
lens[1] = strlen(key);
|
||||
|
@ -14,6 +14,11 @@ dbuf_pool::~dbuf_pool()
|
||||
acl_dbuf_pool_destroy(pool_);
|
||||
}
|
||||
|
||||
void dbuf_pool::dbuf_reset()
|
||||
{
|
||||
acl_dbuf_pool_reset(pool_);
|
||||
}
|
||||
|
||||
void* dbuf_pool::dbuf_alloc(size_t len)
|
||||
{
|
||||
return acl_dbuf_pool_alloc(pool_, len);
|
||||
|
Loading…
Reference in New Issue
Block a user