((atomic)+(POD)+(C++)) = { atomic initialization, of static C++ objects };

I have posted a couple parts of a paper that will show how to realize strongly thread-safe construction and destruction of C++ objects on the fly, in multi-threaded environment. The basic technique is fairly straightforward IMHO. You can use a POD from a C API that can be made up of: extern "C" { /*-- the following types/declarations, --*/ typedef struct pod_s pod_t; typedef pod_t volatile podbase_t; typedef podbase_t *podbaseptr_t; typedef intword_t podref_t; typedef uintword_t podrefadj_t; static int pod_refadd(podbaseptr_t, podrefadj_t); static int pod_refsub(podbaseptr_t, podrefadj_t); /*-- a defeinition of the following pod_t --*/ struct pod_s { podref_t count; void *state; }; /*-- which is staticaly initialized with ---*/ #define PODINIT() {0, 0} /*-- and modified by --*/ int pod_refadd(podbaseptr_t _this, podrefadj_t count) { return /* refcount add logic */; } int pod_refsub(podbaseptr_t _this, podrefadj_t count) { return /* refcount sub logic */; } } //-- as a static member of a static C++ template -- namespace static_pod { template<typename T> struct impl { static podbase_t s_thispodbase; //-- which only has to static API functions that -- //-- operate on integer words and pointers -- static T* acquire(impl<T>*, podrefadj_t); static T* release(impl<T>*, podrefadj_t); }; //-- to its static member and type as -- template<typename T> podbase_t impl<T>::s_thispodbase = PODINIT(); template<typename T> T* impl<T>::acquire(impl<T> *_this, podrefadj_t count) { //-- the parameters for the C API -- int ret = pod_refadd(&impl<T>::s_thispodbase, count) //-- that tells us when to call into the-- if (ret) { //-- constructor logic -- } return ...; } template<typename T> void impl<T>::release(impl<T> *_this, podrefadj_t count) { int ret = pod_refsub(&impl<T>::s_thispodbase, count) if (ret) { //-- or destructor logic-- } return ...; } } of C++ objects in a multi-threaded environment. I think I solved this one. My paper will soon be updated with information on how to fully implement and use my algorithm... I can't really think of another solution that can do what this does... Humm... The paper I am working on will include implementation details' for every aspect of the algorithm. It should updated with a lot more information during the next week... Any thoughts?
participants (1)
-
Chris Thomasson