improved DataChain/DataStackPool templates.
This commit is contained in:
parent
cf13064cea
commit
71d198a335
@ -84,9 +84,11 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
DataChain(const int mc);
|
||||
DataChain();
|
||||
virtual ~DataChain()=default;
|
||||
|
||||
bool Init(const int mc); ///<初始化数据链
|
||||
|
||||
UserNode *Acquire(const int acquire_count); ///<请求一个数据区块
|
||||
bool Release(UserNode *ud); ///<释放一个数据区块
|
||||
};//class DataChain
|
||||
|
@ -24,11 +24,19 @@ namespace hgl
|
||||
|
||||
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);
|
||||
|
||||
end=data_array+max_count;
|
||||
|
||||
series.Init(max_count);
|
||||
}
|
||||
|
||||
~DataStackPool()
|
||||
|
@ -2,11 +2,21 @@
|
||||
|
||||
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;
|
||||
free_count=mc;
|
||||
|
||||
series.Init(mc);
|
||||
node_pool.Init(mc);
|
||||
ud_pool.Init(mc);
|
||||
|
||||
ud_set.PreAlloc(mc);
|
||||
|
||||
start=node_pool.Acquire();
|
||||
|
Loading…
x
Reference in New Issue
Block a user