Add thread safety for std::shared_object_ptr

master
Eduardo Bart 11 years ago
parent 3980f859b7
commit bdbe065c23

@ -281,6 +281,10 @@ else()
set(framework_LIBRARIES ${framework_LIBRARIES} ${SYSTEM_LIBRARIES})
endif()
if(FRAMEWORK_THREAD_SAFE)
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DTHREAD_SAFE)
endif()
if(FRAMEWORK_GRAPHICS)
set(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING)
if(OPENGLES STREQUAL "2.0")

@ -28,12 +28,16 @@
#include <cassert>
#include <ostream>
#ifdef THREAD_SAFE
#include <atomic>
#endif
namespace stdext {
template<class T>
class shared_object_ptr;
typedef unsigned int refcount_t;
typedef unsigned long refcount_t;
class shared_object
{
@ -49,7 +53,11 @@ public:
template<typename T> stdext::shared_object_ptr<T> const_self_cast() { return stdext::shared_object_ptr<T>(const_cast<T*>(this)); }
private:
#ifdef THREAD_SAFE
std::atomic<refcount_t> m_refs;
#else
refcount_t m_refs;
#endif
};
template<class T>

Loading…
Cancel
Save