fix a bugs in guarded_ptr and exempt_ptr
authorkhizmax <libcds.dev@gmail.com>
Mon, 24 Nov 2014 06:59:51 +0000 (09:59 +0300)
committerkhizmax <libcds.dev@gmail.com>
Mon, 24 Nov 2014 06:59:51 +0000 (09:59 +0300)
cds/gc/impl/dhp_decl.h
cds/gc/impl/hp_decl.h
cds/urcu/exempt_ptr.h
tests/test-hdr/ordered_list/hdr_intrusive_michael.h

index 6da2073..e07b196 100644 (file)
@@ -529,8 +529,7 @@ namespace cds { namespace gc {
             */
             void release() CDS_NOEXCEPT
             {
-                if ( m_guard.is_initialized() )
-                    m_guard.clear();
+                free_guard();
             }
 
             //@cond
index bffc526..cd9b1c2 100644 (file)
@@ -533,8 +533,7 @@ namespace cds { namespace gc {
             */
             void release() CDS_NOEXCEPT
             {
-                if ( m_pGuard )
-                    m_pGuard->clear();
+                free_guard();
             }
 
             //@cond
index e86103a..0a7ba1f 100644 (file)
@@ -242,8 +242,8 @@ namespace cds { namespace urcu {
         /// Disposes the pointer. Should be called only outside of RCU critical section
         void release()
         {
-            assert( !rcu::is_locked() );
             if ( !empty() ) {
+                assert( !rcu::is_locked() );
                 rcu::template retire_ptr<disposer>( m_pNode );
                 m_pNode = nullptr;
             }
index 864dcc1..606d7f3 100644 (file)
@@ -478,12 +478,14 @@ namespace ordlist {
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
+                    gp.release();
 
                     gp = l.extract( arrItem[i].nKey );
                     CPPUNIT_ASSERT_EX( gp, "i=" << i );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
+                    gp.release();
 
                     gp = l.get( arrItem[i].nKey );
                     CPPUNIT_CHECK( !gp );
@@ -511,12 +513,14 @@ namespace ordlist {
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
+                    gp.release();
 
                     gp = l.extract_with( itm, other_less() );
                     CPPUNIT_ASSERT_EX( gp, "i=" << i );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_CHECK( gp->nVal == arrItem[i].nVal );
+                    gp.release();
 
                     gp = l.get_with( itm, other_less() );
                     CPPUNIT_CHECK( !gp );
@@ -571,14 +575,15 @@ namespace ordlist {
 
                 for ( int i = 0; i < nLimit; ++i ) {
                     {
-                        {
-                            rcu_lock lock;
-                            value_type * pGet = l.get( a[i] );
-                            CPPUNIT_ASSERT( pGet != nullptr );
-                            CPPUNIT_CHECK( pGet->nKey == a[i] );
-                            CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
-                        }
+                        rcu_lock lock;
+                        value_type * pGet = l.get( a[i] );
+                        CPPUNIT_ASSERT( pGet != nullptr );
+                        CPPUNIT_CHECK( pGet->nKey == a[i] );
+                        CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
+                    }
 
+                    {
+                        rcu_lock lock;
                         ep = l.extract( a[i] );
                         CPPUNIT_ASSERT( ep );
                         CPPUNIT_ASSERT( !ep.empty() );
@@ -586,6 +591,7 @@ namespace ordlist {
                         CPPUNIT_CHECK( (*ep).nVal == a[i] * 2 );
                     }
                     ep.release();
+
                     {
                         rcu_lock lock;
                         CPPUNIT_CHECK( l.get( a[i] ) == nullptr );
@@ -613,14 +619,15 @@ namespace ordlist {
                 for ( int i = 0; i < nLimit; ++i ) {
                     other_item itm( a[i] );
                     {
-                        {
-                            rcu_lock lock;
-                            value_type * pGet = l.get_with( itm, other_less() );
-                            CPPUNIT_ASSERT( pGet != nullptr );
-                            CPPUNIT_CHECK( pGet->nKey == a[i] );
-                            CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
-                        }
+                        rcu_lock lock;
+                        value_type * pGet = l.get_with( itm, other_less() );
+                        CPPUNIT_ASSERT( pGet != nullptr );
+                        CPPUNIT_CHECK( pGet->nKey == a[i] );
+                        CPPUNIT_CHECK( pGet->nVal == a[i] * 2 );
+                    }
 
+                    {
+                        rcu_lock lock;
                         ep = l.extract_with( itm, other_less() );
                         CPPUNIT_ASSERT( ep );
                         CPPUNIT_ASSERT( !ep.empty() );
@@ -628,6 +635,7 @@ namespace ordlist {
                         CPPUNIT_CHECK( ep->nVal == a[i] * 2 );
                     }
                     ep.release();
+
                     {
                         rcu_lock lock;
                         CPPUNIT_CHECK( l.get_with( itm, other_less() ) == nullptr );