newly DataLifecycleManager instead of DataLifetimeCallback,
newly DataClifecycleManager in data collection template<>
This commit is contained in:
parent
2377c39642
commit
1fe8f51faa
@ -6,7 +6,7 @@ namespace hgl
|
||||
/**
|
||||
* 原生数据生命周期处理回调
|
||||
*/
|
||||
template<typename T> struct DataLifetimeCallback
|
||||
template<typename T> struct DataLifecycleManager
|
||||
{
|
||||
virtual bool Create(T *){return true;}
|
||||
virtual void Clear(T *){};
|
||||
@ -31,7 +31,7 @@ namespace hgl
|
||||
/**
|
||||
* 对像生命周期处理回调
|
||||
*/
|
||||
template<typename T> struct ObjectLifetimeCallback:public DataLifetimeCallback<T *>
|
||||
template<typename T> struct ObjectLifecycleManager:public DataLifecycleManager<T *>
|
||||
{
|
||||
virtual bool Create(T **) override {return false;}
|
||||
virtual void Clear(T **obj) override {if(obj&&*obj)delete *obj;}
|
||||
@ -42,17 +42,19 @@ namespace hgl
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if(*obj)
|
||||
delete *obj;
|
||||
|
||||
*obj=nullptr;
|
||||
++obj;
|
||||
}
|
||||
}
|
||||
};//struct ObjectLifetimeCallback
|
||||
};//struct ObjectLifecycleManager
|
||||
|
||||
/**
|
||||
* 缺省对像生命周期处理回调
|
||||
*/
|
||||
template<typename T> struct DefaultObjectLifetimeCallback:public ObjectLifetimeCallback<T>
|
||||
template<typename T> struct DefaultObjectLifetimeCallback:public ObjectLifecycleManager<T>
|
||||
{
|
||||
virtual bool Create(T **obj) override {*obj=new T;return(true);}
|
||||
};//struct DefaultObjectLifetimeCallback
|
@ -185,7 +185,7 @@ namespace hgl
|
||||
* 比如定义了Map<int ID,struct DATA>,直接返回DATA需要复制会消耗一些时间,直接返回DATA *会更好一些
|
||||
*/
|
||||
template<typename K,typename V,typename KVData>
|
||||
V *_Map<K,V,KVData>::GetPointer(const K &key)const
|
||||
V *_Map<K,V,KVData>::GetValuePointer(const K &key)const
|
||||
{
|
||||
int index=Find(key);
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace hgl
|
||||
bool ContainsKey(const K &key)const{return(Find(key)!=-1);} ///<确认这个数据是否存在
|
||||
bool ContainsValue(const V &value)const{return(FindByValue(value)!=-1);} ///<确认这个数据是否存在
|
||||
bool Check(const K &key,const V &value)const; ///<确认数据是否是这个
|
||||
virtual V * GetPointer(const K &key)const; ///<取得数据指针
|
||||
virtual V * GetValuePointer(const K &key)const; ///<取得数据指针
|
||||
virtual int GetValueAndSerial(const K &,V &) const; ///<取得数据与索引
|
||||
bool Get(const K &key,V &value)const{return(GetValueAndSerial(key,value)>=0);} ///<取得数据
|
||||
virtual bool Delete(const K &,V &); ///<将指定数据从列表中移除,并获得这个数据
|
||||
@ -167,8 +167,8 @@ namespace hgl
|
||||
|
||||
typedef _Map<K,V *,KVData> SuperClass;
|
||||
|
||||
ObjectLifetimeCallback<V> *olc;
|
||||
ObjectLifetimeCallback<V> default_olc;
|
||||
ObjectLifecycleManager<V> *olc;
|
||||
ObjectLifecycleManager<V> default_olc;
|
||||
|
||||
void DeleteObject(KVData *ds)
|
||||
{
|
||||
@ -195,7 +195,7 @@ namespace hgl
|
||||
Clear();
|
||||
}
|
||||
|
||||
virtual void SetDataLifetimeCallback(ObjectLifetimeCallback<V> *cb) ///<设定数据生命周期回调函数
|
||||
virtual void SetDataLifetimeCallback(ObjectLifecycleManager<V> *cb) ///<设定数据生命周期回调函数
|
||||
{
|
||||
olc=cb;
|
||||
}
|
||||
|
@ -7,18 +7,20 @@ namespace hgl
|
||||
/**
|
||||
* 对象列表处理类与标准列表处理类的区别在于它对数据清除时会调用delete
|
||||
*/
|
||||
template<typename T> class ObjectList:public List<T *> ///对象列表处理类
|
||||
template<typename T> class ObjectListTemplate:public List<T *> ///对象列表处理类
|
||||
{
|
||||
protected:
|
||||
|
||||
DataLifecycleManager<T> *dlm; ///<数据生命周期回调函数
|
||||
|
||||
public:
|
||||
|
||||
using ItemPointer=T *;
|
||||
|
||||
virtual void DeleteObject(T *obj){if(obj)delete obj;}
|
||||
|
||||
public: //方法
|
||||
|
||||
using List<T *>::List;
|
||||
virtual ~ObjectList(){Free();}
|
||||
ObjectListTemplate(DataLifecycleManager<T> *_dlm):List<T *>(){dlm=_dlm;}
|
||||
virtual ~ObjectListTemplate(){Free();}
|
||||
|
||||
public:
|
||||
|
||||
@ -38,8 +40,7 @@ namespace hgl
|
||||
|
||||
virtual void Clear() override ///<清除所有数据,但不清空缓冲区
|
||||
{
|
||||
for(auto *obj:List<T *>::data_array)
|
||||
DeleteObject(obj);
|
||||
dlm->Clear(this->data_array.GetData(),this->data_array.GetCount());
|
||||
|
||||
List<T *>::Clear();
|
||||
}
|
||||
@ -63,13 +64,7 @@ namespace hgl
|
||||
if(index<0||num<=0||index+num>=List<T *>::GetCount())
|
||||
return(false);
|
||||
|
||||
ItemPointer *p=this->data_array.data()+index;
|
||||
|
||||
for(int i=0;i<num;i++)
|
||||
{
|
||||
DeleteObject(*p);
|
||||
++p;
|
||||
}
|
||||
dlm->Clear(this->data_array.GetData()+index,num);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -121,20 +116,14 @@ namespace hgl
|
||||
{
|
||||
if(!obj_list||num<=0)return(-1);
|
||||
|
||||
ItemPointer *p=(ItemPointer *)obj_list;
|
||||
|
||||
for(int i=0;i<num;i++)
|
||||
{
|
||||
DeleteObject(*p);
|
||||
++p;
|
||||
}
|
||||
dlm->Clear(obj_list,num);
|
||||
|
||||
return List<T *>::DeleteByValue(obj_list,num);
|
||||
}
|
||||
|
||||
virtual T *operator[](int n)const ///<操作符重载取得指定索引处的数据
|
||||
{
|
||||
T **obj=this->data_array.GetPointer(n);
|
||||
T **obj=this->data_array.At(n);
|
||||
|
||||
if(!obj)return(nullptr);
|
||||
|
||||
@ -166,7 +155,7 @@ namespace hgl
|
||||
if(!this->data_array.SetCount(new_count))
|
||||
return(false);
|
||||
|
||||
ItemPointer *p=this->data_array.GetPointer(cur_count);
|
||||
ItemPointer *p=this->data_array.At(cur_count);
|
||||
|
||||
hgl_zero<ItemPointer>(p,new_count-cur_count);
|
||||
|
||||
@ -183,17 +172,27 @@ namespace hgl
|
||||
|
||||
virtual bool Set(int index,const ItemPointer &data) override
|
||||
{
|
||||
ItemPointer *p=this->data_array.GetPointer(index);
|
||||
ItemPointer *p=this->data_array.At(index);
|
||||
|
||||
if(!p)return(false);
|
||||
|
||||
DeleteObject(*p);
|
||||
dlm->Clear(p);
|
||||
*p=data;
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//template <typename T> class ObjectList
|
||||
|
||||
template<typename T> class ObjectList:public ObjectListTemplate<T>
|
||||
{
|
||||
ObjectLifecycleManager<T> DefaultOLM;
|
||||
|
||||
public:
|
||||
|
||||
ObjectList():ObjectListTemplate<T>(&DefaultOLM){}
|
||||
virtual ~ObjectList()=default;
|
||||
};//template<typename T> class ObjectList:public ObjectListTemplate<T>
|
||||
|
||||
#define OBJECT_LIST_ARRAY_FREE(object_list) for(auto &obj:object_list)obj.Free();
|
||||
#define OBJECT_LIST_ARRAY_CLEAR(object_list) for(auto &obj:object_list)obj.Clear();
|
||||
}//namespace hgl
|
||||
|
@ -18,7 +18,7 @@ namespace hgl
|
||||
/**
|
||||
* 对象管理器,它没有缓冲管理,仅仅是统一管理对象,并保证不会被重复加载
|
||||
*/
|
||||
template<typename K,typename V> class ObjectManage
|
||||
template<typename K,typename V> class ObjectManageTemplate
|
||||
{
|
||||
public:
|
||||
|
||||
@ -28,30 +28,28 @@ namespace hgl
|
||||
|
||||
_Map<K,V *,KVObject> items;
|
||||
|
||||
ObjectLifetimeCallback<V> *dlc; ///<数据生命周期回调函数
|
||||
|
||||
ObjectLifetimeCallback<V> default_dlc;
|
||||
ObjectLifecycleManager<V> *olm; ///<数据生命周期回调函数
|
||||
|
||||
public:
|
||||
|
||||
ObjectManage()
|
||||
ObjectManageTemplate(ObjectLifecycleManager<V> *_olm)
|
||||
{
|
||||
dlc=&default_dlc;
|
||||
olm=_olm;
|
||||
}
|
||||
|
||||
virtual ~ObjectManage()
|
||||
virtual ~ObjectManageTemplate()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
virtual void SetDataLifetimeCallback(ObjectLifetimeCallback<V> *cb) ///<设定数据生命周期回调函数
|
||||
virtual void SetDataLifetimeCallback(ObjectLifecycleManager<V> *cb) ///<设定数据生命周期回调函数
|
||||
{
|
||||
dlc=cb;
|
||||
olm=cb;
|
||||
}
|
||||
|
||||
virtual void Clear() ///<清除所有对象
|
||||
{
|
||||
if(dlc)
|
||||
if(olm)
|
||||
{
|
||||
int n=items.GetCount();
|
||||
|
||||
@ -59,7 +57,7 @@ namespace hgl
|
||||
{
|
||||
KVObject *obj=items.GetItem(n);
|
||||
|
||||
dlc->Clear(&(obj->value));
|
||||
olm->Clear(&(obj->value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,8 +74,8 @@ namespace hgl
|
||||
|
||||
if(obj->ref_count<=0)
|
||||
{
|
||||
if(dlc)
|
||||
dlc->Clear(&(obj->value));
|
||||
if(olm)
|
||||
olm->Clear(&(obj->value));
|
||||
|
||||
items.DeleteAt(n);
|
||||
}
|
||||
@ -181,8 +179,8 @@ namespace hgl
|
||||
|
||||
if(zero_clear)
|
||||
{
|
||||
if(dlc)
|
||||
dlc->Clear(&(obj->value));
|
||||
if(olm)
|
||||
olm->Clear(&(obj->value));
|
||||
|
||||
items.DeleteAt(index);
|
||||
}
|
||||
@ -211,7 +209,17 @@ namespace hgl
|
||||
{
|
||||
return ReleaseBySerial(items.FindByValue(td),zero_clear);
|
||||
}
|
||||
};//template<typename K,typename V> class ObjectManage
|
||||
};//template<typename K,typename V> class ObjectManageTemplate
|
||||
|
||||
template<typename K,typename V> class ObjectManage:public ObjectManageTemplate<K,V>
|
||||
{
|
||||
ObjectLifecycleManager<V> DefaultOLM;
|
||||
|
||||
public:
|
||||
|
||||
ObjectManage():ObjectManageTemplate(&DefaultOLM){}
|
||||
virtual ~ObjectManage()=default;
|
||||
};//template<typename K,typename V> class ObjectManage:public ObjectManageTemplate<K,V>
|
||||
|
||||
/**
|
||||
* 使用整型对象类做数标识的对象管理器
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/Queue.h>
|
||||
#include<hgl/type/LifetimeCallback.h>
|
||||
#include<hgl/type/LifecycleManager.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
@ -10,7 +10,7 @@ namespace hgl
|
||||
* 默认情部下空闲队列使用Queue模板管理(先入先出,总是使用最早扔进去的数据。可手动换成Stack运行性能更好,但逻辑性能更差。),
|
||||
* 活动队列使用List模板管理(无序)。
|
||||
*/
|
||||
template<typename T,typename AT,typename IT,typename DEFAULT_DLC> class _Pool ///数据池
|
||||
template<typename T,typename AT,typename IT> class PoolTemplate ///数据池模板
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -28,9 +28,7 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
DataLifetimeCallback<T> *dlc; ///<数据生命周期回调函数
|
||||
|
||||
DEFAULT_DLC default_dlc;
|
||||
DataLifecycleManager<T> *dlm; ///<数据生命周期回调函数
|
||||
|
||||
public: //属性
|
||||
|
||||
@ -53,21 +51,21 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
_Pool()
|
||||
PoolTemplate(DataLifecycleManager<T> *_dlc)
|
||||
{
|
||||
max_active_count=0;
|
||||
history_max=0;
|
||||
dlc=&default_dlc;
|
||||
dlm=_dlc;
|
||||
}
|
||||
|
||||
virtual ~_Pool()
|
||||
virtual ~PoolTemplate()
|
||||
{
|
||||
Clear(); //有一些数据需要特别的Clear处理,所以不能依赖Active/InActive模板本身的自晰构
|
||||
}
|
||||
|
||||
virtual void SetDataLifetimeCallback(DataLifetimeCallback<T> *cb) ///<设定数据生命周期回调函数
|
||||
virtual void SetDataLifetimeCallback(DataLifecycleManager<T> *cb) ///<设定数据生命周期回调函数
|
||||
{
|
||||
dlc=cb;
|
||||
dlm=cb;
|
||||
}
|
||||
|
||||
virtual void PreAlloc(int count,bool set_to_max=false) ///<预分配空间
|
||||
@ -83,12 +81,12 @@ namespace hgl
|
||||
|
||||
virtual bool Create(T &value) ///<创建一个数据,并放置在活跃队列中
|
||||
{
|
||||
if(!dlc)return(false);
|
||||
if(!dlm)return(false);
|
||||
|
||||
if(IsFull())
|
||||
return(false);
|
||||
|
||||
if(!dlc->Create(&value))
|
||||
if(!dlm->Create(&value))
|
||||
return(false);
|
||||
|
||||
Active.Add(value);
|
||||
@ -103,14 +101,14 @@ namespace hgl
|
||||
if(IsFull())
|
||||
return(false);
|
||||
|
||||
if(!dlc)return(false);
|
||||
if(!dlm)return(false);
|
||||
|
||||
if(!dlc->Create(&value))
|
||||
if(!dlm->Create(&value))
|
||||
return(false);
|
||||
}
|
||||
else if(dlc)
|
||||
else if(dlm)
|
||||
{
|
||||
dlc->OnActive(&value);
|
||||
dlm->OnActive(&value);
|
||||
}
|
||||
|
||||
Active.Add(value);
|
||||
@ -123,8 +121,8 @@ namespace hgl
|
||||
if(!Idle.Pop(value))
|
||||
return(false);
|
||||
|
||||
if(dlc)
|
||||
dlc->OnActive(&value);
|
||||
if(dlm)
|
||||
dlm->OnActive(&value);
|
||||
|
||||
Active.Add(value);
|
||||
return(true);
|
||||
@ -160,8 +158,8 @@ namespace hgl
|
||||
if(!Idle.Push(value))
|
||||
return(false);
|
||||
|
||||
if(dlc)
|
||||
dlc->OnIdle(&value);
|
||||
if(dlm)
|
||||
dlm->OnIdle(&value);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -187,8 +185,8 @@ namespace hgl
|
||||
|
||||
virtual void ReleaseActive() ///<释放所有活跃数据
|
||||
{
|
||||
if(dlc)
|
||||
dlc->OnIdle(Active.GetData(),Active.GetCount());
|
||||
if(dlm)
|
||||
dlm->OnIdle(Active.GetData(),Active.GetCount());
|
||||
|
||||
Idle.Push(Active.GetData(),Active.GetCount());
|
||||
Active.Clear();
|
||||
@ -196,15 +194,15 @@ namespace hgl
|
||||
|
||||
virtual void ClearActive()
|
||||
{
|
||||
if(dlc)
|
||||
dlc->Clear(Active.GetData(),Active.GetCount());
|
||||
if(dlm)
|
||||
dlm->Clear(Active.GetData(),Active.GetCount());
|
||||
|
||||
Active.Clear();
|
||||
}
|
||||
|
||||
virtual void ClearIdle() ///<清除所有非活跃数据
|
||||
{
|
||||
Idle.Clear(dlc);
|
||||
Idle.Clear(dlm);
|
||||
}
|
||||
|
||||
virtual void Clear() ///<清除所有数据
|
||||
@ -212,8 +210,18 @@ namespace hgl
|
||||
ClearActive();
|
||||
ClearIdle();
|
||||
}
|
||||
};//template<typename T,typename AT,typename IT> class _Pool
|
||||
};//template<typename T,typename AT,typename IT> class PoolTemplate
|
||||
|
||||
template<typename T> using Pool =_Pool<T, List<T>, Queue<T>, DataLifetimeCallback<T>>; ///<数据池模板
|
||||
template<typename T> using ObjectPool =_Pool<T *, List<T *>, ObjectQueue<T>, ObjectLifetimeCallback<T>>; ///<对象池
|
||||
template<typename T,typename AT,typename IT,typename DLM> class PoolWithDLM:public PoolTemplate<T,AT,IT>
|
||||
{
|
||||
DLM DefaultLifecycleManager;
|
||||
|
||||
public:
|
||||
|
||||
PoolWithDLM():PoolTemplate(&DefaultLifecycleManager){}
|
||||
virtual ~PoolWithDLM()=default;
|
||||
};//template<typename T,typename AT,typename IT,typename DLM> class PoolWithDLM:public PoolTemplate<T,AT,IT>
|
||||
|
||||
template<typename T> using Pool =PoolWithDLM<T, List<T>, Queue<T>, DataLifecycleManager<T>>; ///<数据池模板
|
||||
template<typename T> using ObjectPool =PoolWithDLM<T *, List<T *>, ObjectQueue<T>, ObjectLifecycleManager<T>>; ///<对象池
|
||||
}//namespace hgl
|
||||
|
@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/DataArray.h>
|
||||
#include<hgl/type/LifetimeCallback.h>
|
||||
#include<hgl/type/LifecycleManager.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* Queue模板类用于保存一个先进先出、后进后出的数据队列
|
||||
*/
|
||||
template<typename T> class Queue ///队列顺序数据访问类
|
||||
template<typename T> class QueueTemplate ///队列顺序数据访问类
|
||||
{
|
||||
protected:
|
||||
|
||||
DataLifecycleManager<T> *dlm;
|
||||
|
||||
DataArray<T> data_array[2];
|
||||
|
||||
int read_index;
|
||||
@ -64,14 +66,16 @@ namespace hgl
|
||||
|
||||
public: //方法
|
||||
|
||||
Queue()
|
||||
QueueTemplate(DataLifecycleManager<T> *_dlm)
|
||||
{
|
||||
dlm=_dlm;
|
||||
|
||||
write_index=0;
|
||||
read_index=1;
|
||||
read_offset=0;
|
||||
}
|
||||
|
||||
virtual ~Queue()=default;
|
||||
virtual ~QueueTemplate()=default;
|
||||
|
||||
virtual bool Push (T *data,int count) ///<压入一批数据
|
||||
{
|
||||
@ -128,15 +132,15 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
virtual void Clear (DataLifetimeCallback<T> *dlc=nullptr) ///<清除所有数据
|
||||
virtual void Clear () ///<清除所有数据
|
||||
{
|
||||
if(dlc)
|
||||
if(dlm)
|
||||
{
|
||||
if(data_array[read_index].GetCount()>read_offset) //还有没读完的,需要清掉
|
||||
dlc->Clear(data_array[read_index].GetData()+read_offset,
|
||||
dlm->Clear(data_array[read_index].GetData()+read_offset,
|
||||
data_array[read_index].GetCount()-read_offset);
|
||||
|
||||
dlc->Clear(data_array[write_index].GetData(),
|
||||
dlm->Clear(data_array[write_index].GetData(),
|
||||
data_array[write_index].GetCount());
|
||||
}
|
||||
|
||||
@ -144,22 +148,34 @@ namespace hgl
|
||||
data_array[1].Clear();
|
||||
}
|
||||
|
||||
virtual void Free (DataLifetimeCallback<T> *dlc=nullptr) ///<清除所有数据并释放内存
|
||||
virtual void Free () ///<清除所有数据并释放内存
|
||||
{
|
||||
Clear(dlc);
|
||||
Clear(dlm);
|
||||
|
||||
data_array[0].Free();
|
||||
data_array[1].Free();
|
||||
}
|
||||
};//template<typename T> class Queue
|
||||
};//template<typename T> class QueueTemplate
|
||||
|
||||
template<typename T> class ObjectQueue:public Queue<T *> ///对象队列
|
||||
template<typename T> class Queue:public QueueTemplate<T>
|
||||
{
|
||||
protected:
|
||||
|
||||
DataLifecycleManager<T> DefaultDLM;
|
||||
|
||||
public:
|
||||
|
||||
Queue():QueueTemplate(&DefaultDLM){};
|
||||
virtual ~Queue()=default;
|
||||
};//template<typename T> class Queue:public QueueTemplate<T>
|
||||
|
||||
template<typename T> class ObjectQueue:public QueueTemplate<T *> ///对象队列
|
||||
{
|
||||
DefaultObjectLifetimeCallback<T> default_olc;
|
||||
|
||||
public:
|
||||
|
||||
using Queue<T *>::Queue;
|
||||
ObjectQueue():QueueTemplate(&default_olc){}
|
||||
virtual ~ObjectQueue() override { Free(); }
|
||||
|
||||
virtual bool Push(T *obj)
|
||||
@ -186,7 +202,7 @@ namespace hgl
|
||||
// return obj;
|
||||
//}
|
||||
|
||||
void Clear(DataLifetimeCallback<T *> *olc=nullptr)
|
||||
void Clear(DataLifecycleManager<T *> *olc=nullptr)
|
||||
{
|
||||
if(!olc)
|
||||
olc=&default_olc;
|
||||
@ -194,7 +210,7 @@ namespace hgl
|
||||
Queue<T *>::Clear(olc);
|
||||
}
|
||||
|
||||
void Free(DataLifetimeCallback<T *> *olc=nullptr)
|
||||
void Free(DataLifecycleManager<T *> *olc=nullptr)
|
||||
{
|
||||
ObjectQueue<T>::Clear(olc);
|
||||
|
||||
|
@ -87,17 +87,17 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
virtual void Clear (DataLifetimeCallback<T> *dlc=nullptr) ///<清除所有数据
|
||||
virtual void Clear (DataLifecycleManager<T> *dlm=nullptr) ///<清除所有数据
|
||||
{
|
||||
if(dlc)
|
||||
dlc->Clear(data_array.GetData(),data_array.GetCount());
|
||||
if(dlm)
|
||||
dlm->Clear(data_array.GetData(),data_array.GetCount());
|
||||
|
||||
data_array.Clear();
|
||||
}
|
||||
|
||||
virtual void Free (DataLifetimeCallback<T> *dlc=nullptr) ///<清除所有数据并释放内存
|
||||
virtual void Free (DataLifecycleManager<T> *dlm=nullptr) ///<清除所有数据并释放内存
|
||||
{
|
||||
Clear(dlc);
|
||||
Clear(dlm);
|
||||
data_array.Free();
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ namespace hgl
|
||||
return obj;
|
||||
}
|
||||
|
||||
void Clear(ObjectLifetimeCallback<T> *olc=nullptr)
|
||||
void Clear(ObjectLifecycleManager<T> *olc=nullptr)
|
||||
{
|
||||
if(!olc)
|
||||
olc=&default_olc;
|
||||
@ -145,7 +145,7 @@ namespace hgl
|
||||
Stack<T *>::Clear(olc);
|
||||
}
|
||||
|
||||
void Free(ObjectLifetimeCallback<T> *olc=nullptr)
|
||||
void Free(ObjectLifecycleManager<T> *olc=nullptr)
|
||||
{
|
||||
ObjectStack<T>::Clear(olc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user