the greater the value of longevity the greater the lifetime.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@280 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
622a426739
commit
13d56ada49
1 changed files with 10 additions and 2 deletions
|
@ -52,7 +52,7 @@ namespace Loki
|
||||||
static bool Compare(const LifetimeTracker* lhs,
|
static bool Compare(const LifetimeTracker* lhs,
|
||||||
const LifetimeTracker* rhs)
|
const LifetimeTracker* rhs)
|
||||||
{
|
{
|
||||||
return lhs->longevity_ < rhs->longevity_;
|
return lhs->longevity_ > rhs->longevity_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -71,6 +71,7 @@ namespace Loki
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Deleter
|
struct Deleter
|
||||||
{
|
{
|
||||||
|
typedef void (*Type)(T*);
|
||||||
static void Delete(T* pObj)
|
static void Delete(T* pObj)
|
||||||
{ delete pObj; }
|
{ delete pObj; }
|
||||||
};
|
};
|
||||||
|
@ -105,7 +106,7 @@ namespace Loki
|
||||||
|
|
||||||
template <typename T, typename Destroyer>
|
template <typename T, typename Destroyer>
|
||||||
void SetLongevity(T* pDynObject, unsigned int longevity,
|
void SetLongevity(T* pDynObject, unsigned int longevity,
|
||||||
Destroyer d = Private::Deleter<T>::Delete)
|
Destroyer d)
|
||||||
{
|
{
|
||||||
using namespace Private;
|
using namespace Private;
|
||||||
|
|
||||||
|
@ -137,6 +138,13 @@ namespace Loki
|
||||||
std::atexit(Private::AtExitFn);
|
std::atexit(Private::AtExitFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SetLongevity(T* pDynObject, unsigned int longevity,
|
||||||
|
typename Private::Deleter<T>::Type d = Private::Deleter<T>::Delete)
|
||||||
|
{
|
||||||
|
SetLongevity<T, typename Private::Deleter<T>::Type>(pDynObject, longevity, d);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// class template CreateUsingNew
|
// class template CreateUsingNew
|
||||||
// Implementation of the CreationPolicy used by SingletonHolder
|
// Implementation of the CreationPolicy used by SingletonHolder
|
||||||
|
|
Loading…
Add table
Reference in a new issue