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 6da2073a658364a0661988b6929052101d157a63..e07b196c3c62b3121dee47849a2af76cb25e7951 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 bffc52687ad8139178050d7d72aee4dc9b13dbff..cd9b1c2b406352028432e1d3b179e66f936873bf 100644 (file)
@@ -533,8 +533,7 @@ namespace cds { namespace gc {
             */
             void release() CDS_NOEXCEPT
             {
-                if ( m_pGuard )
-                    m_pGuard->clear();
+                free_guard();
             }
 
             //@cond
index e86103a145db4acc28cd5a672181378cd0425045..0a7ba1f55262b5146e13f14a43594131319b96fa 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 864dcc1e2595a39663d7bccb8d080780553e0847..606d7f34390f4da54858d81fde493bdbaf9693b9 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 );