6 #ifndef __singleton_h__
7 #define __singleton_h__
41 {
return lval += val; }
44 {
return lval -= val; }
47 {
return lval *= val; }
50 {
return lval /= val; }
101 template <
typename T>
109 template <
typename T,
typename Destroyer>
137 template <
typename T,
typename Destroyer>
141 using namespace Private;
145 if (!pNewArray)
throw std::bad_alloc();
147 LifetimeTracker*
p =
new ConcreteLifetimeTracker<T, Destroyer>(
148 pDynObject, longevity,
d);
196 void*
p = std::malloc(
sizeof(
T));
236 return new(&staticMemory_)
T;
256 { std::atexit(pFun); }
259 {
throw std::logic_error(
"Dead Reference Detected"); }
267 { std::atexit(pFun); }
270 {
throw std::logic_error(
"Dead Reference Detected"); }
278 { std::atexit(pFun); }
281 {
throw std::logic_error(
"Dead Reference Detected"); }
354 {
throw std::logic_error(
"Dead Reference Detected"); }
380 template <
typename T,
381 template <
class>
class CreationPolicy = CreateUsingNew,
382 template <
class>
class LifetimePolicy = DefaultLifetime,
383 template <
class>
class ThreadingModel = SingleThreaded>
408 template <
class>
class C,
409 template <
class>
class L,
410 template <
class>
class M>
417 template <
class>
class C,
418 template <
class>
class L,
419 template <
class>
class M
428 template <
class>
class CreationPolicy,
429 template <
class>
class LifetimePolicy,
430 template <
class>
class ThreadingModel>
432 LifetimePolicy, ThreadingModel>::Instance()
446 template <
class>
class CreationPolicy,
447 template <
class>
class LifetimePolicy,
448 template <
class>
class ThreadingModel>
450 LifetimePolicy, ThreadingModel>::MakeInstance()
452 typename ThreadingModel<T>::Lock guard;
459 LifetimePolicy<T>::OnDeadReference();
462 pInstance_ = CreationPolicy<T>::Create();
463 LifetimePolicy<T>::ScheduleDestruction(pInstance_,
469 template <
class>
class CreationPolicy,
470 template <
class>
class L,
471 template <
class>
class M>
475 CreationPolicy<T>::Destroy(pInstance_);
static void OnDeadReference()
static bool destroyedOnce_
static void ScheduleDestruction(T *, void(*pFun)())
~ConcreteLifetimeTracker()
ConcreteLifetimeTracker(T *p, unsigned int longevity, Destroyer d)
virtual ~LifetimeTracker()=0
static bool Compare(const LifetimeTracker *lhs, const LifetimeTracker *rhs)
LifetimeTracker(unsigned int x)
static IntType AtomicDivide(volatile IntType &lval)
static IntType AtomicMultiply(volatile IntType &lval, IntType val)
static IntType AtomicAdd(volatile IntType &lval, IntType val)
static IntType AtomicSubtract(volatile IntType &lval, IntType val)
static void AtomicAssign(volatile IntType &lval, IntType val)
static IntType AtomicIncrement(volatile IntType &lval)
static IntType AtomicDivide(volatile IntType &lval, IntType val)
static void AtomicAssign(IntType &lval, volatile IntType &val)
static void MakeInstance()
static PtrInstanceType pInstance_
static void DestroySingleton()
ThreadingModel< T * >::VolatileType PtrInstanceType
static void ScheduleDestruction(T *pObj, void(*pFun)())
static void OnDeadReference()
SpinMatrix C()
C = Gamma(10)
TrackerArray pTrackerArray
LifetimeTracker ** TrackerArray
Asqtad Staggered-Dirac operator.
void SetLongevity(T *pDynObject, unsigned int longevity, Destroyer d=Private::Deleter< T >::Delete)
LinOpSysSolverMGProtoClover::T T
static void Destroy(T *p)
static void Destroy(T *p)
static void Destroy(T *p)
static void ScheduleDestruction(T *, void(*pFun)())
static void OnDeadReference()
static void OnDeadReference()
static void ScheduleDestruction(T *, void(*pFun)())
static void OnDeadReference()
static void ScheduleDestruction(T *, void(*pFun)())
static void OnDeadReference()
static void ScheduleDestruction(T *, void(*)())
static void Delete(T *pObj)
int(Test::* pMemberFn_)(int)