drop suncc support from singleton class

This commit is contained in:
Dane Springmeyer 2013-09-18 20:29:46 -07:00
parent 9aff3c596b
commit 8b5323f101

View file

@ -84,54 +84,36 @@ public:
static MaxAlign staticMemory; static MaxAlign staticMemory;
return new(&staticMemory) T; return new(&staticMemory) T;
} }
#ifdef __SUNPRO_CC static void destroy(volatile T* obj)
// Sun C++ Compiler doesn't handle `volatile` keyword same as GCC.
static void destroy(T* obj)
#else
static void destroy(volatile T* obj)
#endif
{ {
obj->~T(); obj->~T();
} }
}; };
#ifdef __GNUC__
template <typename T, template <typename T,
template <typename U> class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton template <typename U> class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton
{ {
#else friend class CreatePolicy<T>;
template <typename T, static T* pInstance_;
template <typename U> class CreatePolicy=CreateStatic> class singleton static bool destroyed_;
singleton(const singleton &rhs);
singleton& operator=(const singleton&);
static void onDeadReference()
{ {
#endif throw std::runtime_error("dead reference!");
}
#ifdef __SUNPRO_CC static void DestroySingleton()
/* Sun's C++ compiler will issue the following errors if CreatePolicy<T> is used: {
Error: A class template name was expected instead of mapnik::CreatePolicy<mapnik::T> CreatePolicy<T>::destroy(pInstance_);
Error: A "friend" declaration must specify a class or function. pInstance_ = 0;
*/ destroyed_ = true;
friend class CreatePolicy; }
#else
friend class CreatePolicy<T>;
#endif
static T* pInstance_;
static bool destroyed_;
singleton(const singleton &rhs);
singleton& operator=(const singleton&);
static void onDeadReference() protected:
{
throw std::runtime_error("dead reference!");
}
static void DestroySingleton()
{
CreatePolicy<T>::destroy(pInstance_);
pInstance_ = 0;
destroyed_ = true;
}
protected:
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
static mutex mutex_; static mutex mutex_;
#endif #endif
@ -162,7 +144,8 @@ template <typename T,
} }
return *pInstance_; return *pInstance_;
} }
}; };
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
template <typename T, template <typename T,
template <typename U> class CreatePolicy> mutex singleton<T,CreatePolicy>::mutex_; template <typename U> class CreatePolicy> mutex singleton<T,CreatePolicy>::mutex_;