add GetActiveCount()/GetInactiveCount()/IsActive()/IsInactive() in Pool<>
This commit is contained in:
parent
6403f8039e
commit
b003585d43
@ -32,6 +32,9 @@ namespace hgl
|
||||
max_count=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
max_count=mc;
|
||||
return mc;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -42,7 +45,7 @@ namespace hgl
|
||||
if(max_count>0&&alloc_count>=max_count)
|
||||
return(false);
|
||||
|
||||
result=Create();
|
||||
value=Create();
|
||||
|
||||
alloc_count++;
|
||||
|
||||
@ -57,7 +60,11 @@ namespace hgl
|
||||
template<typename T>
|
||||
bool Pool<T>::Get(T &value)
|
||||
{
|
||||
return Inactive.Pop(value);
|
||||
if(!Inactive.Pop(value))
|
||||
return(false);
|
||||
|
||||
Active.Add(value);
|
||||
return(true);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -125,7 +132,7 @@ namespace hgl
|
||||
template<typename T>
|
||||
void Pool<T>::Clear(T *dp,int dc)
|
||||
{
|
||||
for(int i=0;i<ic;i++)
|
||||
for(int i=0;i<dc;i++)
|
||||
{
|
||||
Clear(*dp);
|
||||
++dp;
|
||||
|
@ -36,6 +36,9 @@ namespace hgl
|
||||
int GetInactiveCount() const{return Inactive.GetCount();} ///<取得非活动数据数量
|
||||
int GetHistoryMaxCount()const{return history_max;} ///<取得历史性最大数据数量
|
||||
|
||||
T *GetActiveData ()const{return Active.GetData();} ///<取得所有活跃数据
|
||||
T *GetInactiveData ()const{return Inactive.GetData();} ///<取得所有非活跃数据
|
||||
|
||||
public:
|
||||
|
||||
Pool(){alloc_count=0;history_max=0;max_count=0;}
|
||||
@ -52,6 +55,9 @@ namespace hgl
|
||||
virtual int Release(T *,int); ///<释放一批数据
|
||||
virtual int ReleaseAll(); ///<释放所有数据
|
||||
|
||||
bool IsActive(const T &data)const{return Active.IsExist(data);}
|
||||
bool IsInactive(const T &data)const{return Inactive.IsExist(data);}
|
||||
|
||||
virtual void ClearInactive(); ///<清除所有空闲的
|
||||
virtual void ClearAll(); ///<清除所有的
|
||||
};//template<typename T> class Pool
|
||||
|
Loading…
x
Reference in New Issue
Block a user