X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=blobdiff_plain;f=cds%2Fgc%2Fimpl%2Fhp_decl.h;h=bffc52687ad8139178050d7d72aee4dc9b13dbff;hp=56c1db6ffa53b62791ab2098aac71b90b525397f;hb=e9fda6acf3c6a28fb822cfe85d784682eb8dbbe0;hpb=6ea0026d2fa15c062d315a73892100d132a362ec diff --git a/cds/gc/impl/hp_decl.h b/cds/gc/impl/hp_decl.h index 56c1db6f..bffc5268 100644 --- a/cds/gc/impl/hp_decl.h +++ b/cds/gc/impl/hp_decl.h @@ -477,9 +477,16 @@ namespace cds { namespace gc { /// Move-assignment operator guarded_ptr& operator=( guarded_ptr&& gp ) CDS_NOEXCEPT { - free_guard(); - m_pGuard = gp.m_pGuard; - gp.m_pGuard = nullptr; + // Hazard Pointer array is organized as a stack + if ( m_pGuard && m_pGuard > gp.m_pGuard ) { + m_pGuard->set( gp.m_pGuard->get(atomics::memory_order_relaxed) ); + gp.free_guard(); + } + else { + free_guard(); + m_pGuard = gp.m_pGuard; + gp.m_pGuard = nullptr; + } return *this; } @@ -510,7 +517,7 @@ namespace cds { namespace gc { /// Checks if the guarded pointer is \p nullptr bool empty() const CDS_NOEXCEPT { - return !m_pGuard || m_pGuard->get() == nullptr; + return !m_pGuard || m_pGuard->get( atomics::memory_order_relaxed ) == nullptr; } /// \p bool operator returns !empty()