2015-01-04 22:51:01 +08:00
|
|
|
|
#pragma once
|
2015-01-26 19:58:02 +08:00
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
2015-01-04 22:51:01 +08:00
|
|
|
|
|
|
|
|
|
struct ACL_DBUF_POOL;
|
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
2015-01-26 19:58:02 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>亯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻһ<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD>ͷţ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪƵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD>С<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ã<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>װ<EFBFBD><EFBFBD> lib_acl <EFBFBD>е<EFBFBD> ACL_DBUF_POOL <EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
class ACL_CPP_API dbuf_pool
|
2015-01-04 22:51:01 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-01-26 19:58:02 +08:00
|
|
|
|
dbuf_pool(size_t block_size = 8192);
|
2015-01-04 22:51:01 +08:00
|
|
|
|
~dbuf_pool();
|
|
|
|
|
|
2015-01-26 19:58:02 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
* @param len {size_t} <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ泤<EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>Ƚ<EFBFBD>Сʱ(С<EFBFBD>ڹ<EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>
|
|
|
|
|
* block_size)ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dbuf_pool <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ϴ<EFBFBD>ʱ
|
|
|
|
|
* <EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> malloc <EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*/
|
2015-01-04 22:51:01 +08:00
|
|
|
|
void* dbuf_alloc(size_t len);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD>ڴ沢<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param len {size_t} <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ泤<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*/
|
2015-01-04 22:51:01 +08:00
|
|
|
|
void* dbuf_calloc(size_t len);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD>ڴ沢<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> strdup
|
|
|
|
|
* @param s {const char*} Դ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {char*} <EFBFBD>¸<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*/
|
2015-01-04 22:51:01 +08:00
|
|
|
|
char* dbuf_strdup(const char* s);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ沢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param s {const void*} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @param len {size_t} Դ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD>¸<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
|
|
|
*/
|
2015-01-04 22:51:01 +08:00
|
|
|
|
void* dbuf_memdup(const void* s, size_t len);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ACL_DBUF_POOL* pool_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|