Improving gc:HP and gc::DHP guards
[libcds.git] / cds / gc / impl / dhp_impl.h
index f4535bd56f766961a2d27681511b068f5b8e9ad5..52fca6bf0908d8b9a4c26198c3bda5c98b7a9503 100644 (file)
@@ -8,6 +8,32 @@
 //@cond
 namespace cds { namespace gc {
 
+    namespace dhp {
+
+        inline Guard::Guard()
+        {
+            cds::threading::getGC<DHP>().allocGuard( *this );
+        }
+
+        inline Guard::~Guard()
+        {
+            cds::threading::getGC<DHP>().freeGuard( *this );
+        }
+
+        template <size_t Count>
+        inline GuardArray<Count>::GuardArray()
+        {
+            cds::threading::getGC<DHP>().allocGuard( *this );
+        }
+
+        template <size_t Count>
+        inline GuardArray<Count>::~GuardArray()
+        {
+            cds::threading::getGC<DHP>().freeGuard( *this );
+        }
+    } // namespace dhp
+
+
     inline DHP::thread_gc::thread_gc(
         bool    bPersistent
         )
@@ -23,14 +49,14 @@ namespace cds { namespace gc {
             cds::threading::Manager::detachThread();
     }
 
-    inline DHP::Guard::Guard()
-        : Guard::base_class( cds::threading::getGC<DHP>() )
-    {}
-
-    template <size_t Count>
-    inline DHP::GuardArray<Count>::GuardArray()
-        : GuardArray::base_class( cds::threading::getGC<DHP>() )
-    {}
+    inline /*static*/ void DHP::thread_gc::alloc_guard( cds::gc::dhp::details::guard& g )
+    {
+        return cds::threading::getGC<DHP>().allocGuard(g);
+    }
+    inline /*static*/ void DHP::thread_gc::free_guard( cds::gc::dhp::details::guard& g )
+    {
+        cds::threading::getGC<DHP>().freeGuard(g);
+    }
 
     inline void DHP::scan()
     {