improved DataChain/DataStackPool templates.

This commit is contained in:
hyzboy 2024-04-01 23:31:11 +08:00
parent cf13064cea
commit 71d198a335
3 changed files with 23 additions and 3 deletions

View File

@ -84,9 +84,11 @@ namespace hgl
public: public:
DataChain(const int mc); DataChain();
virtual ~DataChain()=default; virtual ~DataChain()=default;
bool Init(const int mc); ///<初始化数据链
UserNode *Acquire(const int acquire_count); ///<请求一个数据区块 UserNode *Acquire(const int acquire_count); ///<请求一个数据区块
bool Release(UserNode *ud); ///<释放一个数据区块 bool Release(UserNode *ud); ///<释放一个数据区块
};//class DataChain };//class DataChain

View File

@ -24,11 +24,19 @@ namespace hgl
public: public:
DataStackPool(const int max_count):series(max_count) DataStackPool()
{
data_array=nullptr;
end=nullptr;
}
bool Init(const int max_count)
{ {
data_array=hgl_zero_new<T>(max_count); data_array=hgl_zero_new<T>(max_count);
end=data_array+max_count; end=data_array+max_count;
series.Init(max_count);
} }
~DataStackPool() ~DataStackPool()

View File

@ -2,11 +2,21 @@
namespace hgl namespace hgl
{ {
DataChain::DataChain(const int mc):series(mc),node_pool(mc),ud_pool(mc) DataChain::DataChain()
{
max_count=0;
free_count=0;
}
bool DataChain::Init(const int mc)
{ {
max_count=mc; max_count=mc;
free_count=mc; free_count=mc;
series.Init(mc);
node_pool.Init(mc);
ud_pool.Init(mc);
ud_set.PreAlloc(mc); ud_set.PreAlloc(mc);
start=node_pool.Acquire(); start=node_pool.Acquire();