//@cond
/// Initializes guarded pointer with \p p
- guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
+ explicit guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
{
alloc_guard();
assert( m_pGuard );
m_pGuard->set(p);
}
- guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
+ explicit guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
: m_pGuard( nullptr )
{}
//@endcond
/// 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;
}
/// 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 <tt>!empty()</tt>