typedef typename gc::scoped_lock rcu_lock ; ///< RCU scoped lock
/// pointer to extracted node
- typedef cds::urcu::exempt_ptr< gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
- cds::urcu::details::conventional_exempt_member_cast<leaf_node, value_type>
- > exempt_ptr;
+ using exempt_ptr = cds::urcu::exempt_ptr < gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
+ cds::urcu::details::conventional_exempt_member_cast < leaf_node, value_type >
+ >;
public:
/// Default constructor
/// Extracts an item with minimal key from the map
/**
- If the map is not empty, the function returns \p true, \p result contains a pointer to value.
- If the map is empty, the function returns \p false, \p result is left unchanged.
+ Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the leftmost item.
+ If the set is empty, returns empty \p exempt_ptr.
@note Due the concurrent nature of the map, the function extracts <i>nearly</i> minimum key.
It means that the function gets leftmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not free the item.
- The deallocator will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The deallocator will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
- bool extract_min( exempt_ptr& result )
+ exempt_ptr extract_min()
{
- return base_class::extract_min_( result );
+ return exempt_ptr( base_class::extract_min_());
}
/// Extracts an item with maximal key from the map
/**
- If the map is not empty, the function returns \p true, \p result contains a pointer to extracted item.
- If the map is empty, the function returns \p false, \p result is left unchanged.
+ Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the rightmost item.
+ If the set is empty, returns empty \p exempt_ptr.
@note Due the concurrent nature of the map, the function extracts <i>nearly</i> maximal key.
It means that the function gets rightmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not free the item.
- The deallocator will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
+ The deallocator will be implicitly invoked when the returned object is destroyed or when
+ its \p release() is called.
@note Before reusing \p result object you should call its \p release() method.
*/
- bool extract_max( exempt_ptr& result )
+ exempt_ptr extract_max()
{
- return base_class::extract_max_( result );
+ return exempt_ptr( base_class::extract_max_());
}
/// Extracts an item from the map
/** \anchor cds_nonintrusive_EllenBinTreeMap_rcu_extract
The function searches an item with key equal to \p key in the tree,
- unlinks it, and returns pointer to an item found in \p result parameter.
- If \p key is not found the function returns \p false.
+ unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to an item found.
+ If \p key is not found the function returns an empty \p exempt_ptr.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not destroy the item found.
- The dealloctor will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The dealloctor will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
template <typename Q>
- bool extract( exempt_ptr& result, Q const& key )
+ exempt_ptr extract( Q const& key )
{
- return base_class::extract_( result, key, typename base_class::node_compare());
+ return exempt_ptr( base_class::extract_( key, typename base_class::node_compare()));
}
/// Extracts an item from the map using \p pred for searching
\p pred must imply the same element order as the comparator used for building the map.
*/
template <typename Q, typename Less>
- bool extract_with( exempt_ptr& result, Q const& val, Less pred )
+ exempt_ptr extract_with( Q const& val, Less pred )
{
- return base_class::extract_with_( result, val,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
+ return exempt_ptr( base_class::extract_with_( val,
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() ));
}
/// Find the key \p key
typedef typename gc::scoped_lock rcu_lock; ///< RCU scoped lock
/// pointer to extracted node
- typedef cds::urcu::exempt_ptr< gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
- cds::urcu::details::conventional_exempt_member_cast<leaf_node, value_type>
- > exempt_ptr;
+ using exempt_ptr = cds::urcu::exempt_ptr < gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
+ cds::urcu::details::conventional_exempt_member_cast < leaf_node, value_type >
+ > ;
public:
/// Default constructor
/// Extracts an item with minimal key from the set
/**
- If the set is not empty, the function returns \p true, \p result contains a pointer to value.
- If the set is empty, the function returns \p false, \p result is left unchanged.
+ Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the leftmost item.
+ If the set is empty, returns empty \p exempt_ptr.
@note Due the concurrent nature of the set, the function extracts <i>nearly</i> minimum key.
It means that the function gets leftmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not free the item.
- The deallocator will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The deallocator will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
- bool extract_min( exempt_ptr& result )
+ exempt_ptr extract_min()
{
- return base_class::extract_min_( result );
+ return exempt_ptr( base_class::extract_min_());
}
/// Extracts an item with maximal key from the set
/**
- If the set is not empty, the function returns \p true, \p result contains a pointer to extracted item.
- If the set is empty, the function returns \p false, \p result is left unchanged.
+ Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the rightmost item.
+ If the set is empty, returns empty \p exempt_ptr.
@note Due the concurrent nature of the set, the function extracts <i>nearly</i> maximal key.
It means that the function gets rightmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not free the item.
- The deallocator will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The deallocator will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
- bool extract_max( exempt_ptr& result )
+ exempt_ptr extract_max()
{
- return base_class::extract_max_( result );
+ return exempt_ptr( base_class::extract_max_());
}
/// Extracts an item from the set
/** \anchor cds_nonintrusive_EllenBinTreeSet_rcu_extract
The function searches an item with key equal to \p key in the tree,
- unlinks it, and returns pointer to an item found in \p result parameter.
- If \p key is not found the function returns \p false.
+ unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to an item found.
+ If \p key is not found the function returns an empty \p exempt_ptr.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not destroy the item found.
- The dealloctor will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The dealloctor will be implicitly invoked when the returned object is destroyed or when
+ its release() member function is called.
*/
template <typename Q>
- bool extract( exempt_ptr& result, Q const& key )
+ exempt_ptr extract( Q const& key )
{
- return base_class::extract_( result, key, typename base_class::node_compare());
+ return exempt_ptr( base_class::extract_( key, typename base_class::node_compare()));
}
/// Extracts an item from the set using \p pred for searching
\p pred must imply the same element order as the comparator used for building the set.
*/
template <typename Q, typename Less>
- bool extract_with( exempt_ptr& result, Q const& val, Less pred )
+ exempt_ptr extract_with( Q const& val, Less pred )
{
- return base_class::extract_with_( result, val,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() );
+ return exempt_ptr( base_class::extract_with_( val,
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() ));
}
/// Find the key \p key
//@endcond
public:
- typedef cds::urcu::exempt_ptr< gc, value_type, value_type, disposer, void > exempt_ptr; ///< pointer to extracted node
+ using exempt_ptr = cds::urcu::exempt_ptr< gc, value_type, value_type, disposer, void >; ///< pointer to extracted node
public:
# ifdef CDS_DOXYGEN_INVOKED
/// Extracts an item with minimal key from the tree
/**
- The function searches an item with minimal key, unlinks it, and returns pointer to an item found in \p result parameter.
- If the tree is empty the function returns \p false.
+ The function searches an item with minimal key, unlinks it, and returns
+ \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the leftmost item.
+ If the tree is empty the function returns empty \p exempt_ptr.
@note Due the concurrent nature of the tree, the function extracts <i>nearly</i> minimum key.
It means that the function gets leftmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not call the disposer for the item found.
- The disposer will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The disposer will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
- bool extract_min(exempt_ptr& result)
+ exempt_ptr extract_min()
{
- return extract_min_(result);
+ return exempt_ptr( extract_min_() );
}
/// Extracts an item with maximal key from the tree
/**
- The function searches an item with maximal key, unlinks it, and returns pointer to an item found in \p result prameter.
- If the tree is empty the function returns \p false.
+ The function searches an item with maximal key, unlinks it, and returns
+ \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the rightmost item.
+ If the tree is empty the function returns empty \p exempt_ptr.
@note Due the concurrent nature of the tree, the function extracts <i>nearly</i> maximal key.
It means that the function gets rightmost leaf of the tree and tries to unlink it.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not call the disposer for the item found.
- The disposer will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The disposer will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
- bool extract_max(exempt_ptr& result)
+ exempt_ptr extract_max()
{
- return extract_max_(result);
+ return exempt_ptr( extract_max_() );
}
/// Extracts an item from the tree
/** \anchor cds_intrusive_EllenBinTree_rcu_extract
The function searches an item with key equal to \p key in the tree,
- unlinks it, and returns pointer to an item found in \p result parameter.
- If the item with the key equal to \p key is not found the function returns \p false.
+ unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to an item found.
+ If the item with the key equal to \p key is not found the function returns empty \p exempt_ptr.
RCU \p synchronize method can be called. RCU should NOT be locked.
The function does not call the disposer for the item found.
- The disposer will be implicitly invoked when \p result object is destroyed or when
- <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
- @note Before reusing \p result object you should call its \p release() method.
+ The disposer will be implicitly invoked when the returned object is destroyed or when
+ its \p release() member function is called.
*/
template <typename Q>
- bool extract( exempt_ptr& result, Q const& key )
+ exempt_ptr extract( Q const& key )
{
- return extract_( result, key, node_compare() );
+ return exempt_ptr( extract_( key, node_compare() ));
}
/// Extracts an item from the set using \p pred for searching
\p pred must imply the same element order as the comparator used for building the tree.
*/
template <typename Q, typename Less>
- bool extract_with( exempt_ptr& dest, Q const& key, Less pred )
+ exempt_ptr extract_with( Q const& key, Less pred )
{
- return extract_with_( dest, key, pred );
+ return exempt_ptr( extract_with_( key, pred ));
}
/// Finds the key \p key
*/
void clear()
{
- exempt_ptr ep;
- while ( extract_min(ep) )
+ for ( exempt_ptr ep = extract_min(); !ep.empty(); ep = extract_min() )
ep.release();
}
return true;
}
- template <typename ExemptPtr, typename Q, typename Less>
- bool extract_with_( ExemptPtr& dest, Q const& val, Less pred )
+ template <typename Q, typename Less>
+ value_type * extract_with_( Q const& val, Less pred )
{
typedef ellen_bintree::details::compare<
key_type,
node_traits
> compare_functor;
- return extract_( dest, val, compare_functor() );
+ return extract_( val, compare_functor() );
}
- template <typename ExemptPtr, typename Q, typename Compare>
- bool extract_( ExemptPtr& ptr, Q const& val, Compare cmp )
+ template <typename Q, typename Compare>
+ value_type * extract_( Q const& val, Compare cmp )
{
check_deadlock_policy::check();
update_desc * pOp = nullptr;
search_result res;
back_off bkoff;
+ value_type * pResult;
{
rcu_lock l;
if ( pOp )
retire_update_desc( pOp, updRetire, false );
m_Stat.onEraseFailed();
- return false;
+ return nullptr;
}
if ( res.updGrandParent.bits() != update_desc::Clean )
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( help_delete( pOp, updRetire )) {
- ptr = node_traits::to_value_ptr( res.pLeaf );
+ pResult = node_traits::to_value_ptr( res.pLeaf );
break;
}
pOp = nullptr;
--m_ItemCounter;
m_Stat.onEraseSuccess();
- return true;
+ return pResult;
}
- template <typename ExemptPtr>
- bool extract_max_( ExemptPtr& result )
+ value_type * extract_max_()
{
check_deadlock_policy::check();
update_desc * pOp = nullptr;
search_result res;
back_off bkoff;
+ value_type * pResult;
{
rcu_lock l;
if ( pOp )
retire_update_desc( pOp, updRetire, false );
m_Stat.onExtractMaxFailed();
- return false;
+ return nullptr;
}
if ( res.updGrandParent.bits() != update_desc::Clean )
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( help_delete( pOp, updRetire )) {
- result = node_traits::to_value_ptr( res.pLeaf );
+ pResult = node_traits::to_value_ptr( res.pLeaf );
break;
}
pOp = nullptr;
--m_ItemCounter;
m_Stat.onExtractMaxSuccess();
- return true;
+ return pResult;
}
- template <typename ExemptPtr>
- bool extract_min_(ExemptPtr& result)
+ value_type * extract_min_()
{
check_deadlock_policy::check();
update_desc * pOp = nullptr;
search_result res;
back_off bkoff;
+ value_type * pResult;
{
rcu_lock l;
if ( pOp )
retire_update_desc( pOp, updRetire, false );
m_Stat.onExtractMinFailed();
- return false;
+ return nullptr;
}
if ( res.updGrandParent.bits() != update_desc::Clean )
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( help_delete( pOp, updRetire )) {
- result = node_traits::to_value_ptr( res.pLeaf );
+ pResult = node_traits::to_value_ptr( res.pLeaf );
break;
}
pOp = nullptr;
--m_ItemCounter;
m_Stat.onExtractMinSuccess();
- return true;
+ return pResult;
}
template <typename Q, typename Less, typename Func>
/**
This special pointer class is intended for returning extracted node from RCU-based container.
The destructor (and \p release() member function) invokes <tt>RCU::retire_ptr< Disposer >()</tt> function to dispose the node.
- For non-intrusive containers from \p cds::container namespace \p Disposer is an invocation
+ For non-intrusive containers from \p cds::container namespace \p Disposer is usually an invocation
of node deallocator. For intrusive containers the disposer can be empty or it can trigger an event "node can be reused safely".
In any case, the exempt pointer concept keeps RCU semantics.
- You don't need use this helper class directly. Any RCU-based container defines a proper typedef for this template.
+ You don't need use this helper class directly. Any RCU-based container typedefs a simplified version of this template.
Template arguments:
- \p RCU - one of \ref cds_urcu_gc "RCU type"
- \p NodeType - container's node type
- \p ValueType - value type stored in container's node. For intrusive containers it is the same as \p NodeType
- \p Disposer - a disposer functor
- - \p Cast - a functor for casting from \p NodeType to \p ValueType. Usually, for intrusive containers \p Cast may be \p void.
+ - \p Cast - a functor for casting from \p NodeType to \p ValueType. For intrusive containers
+ the casting is usually disabled, i.e. \p Cast is \p void.
*/
template <
class RCU,
>
class exempt_ptr
{
- //TODO: use move semantics and explicit operator bool!
public:
typedef RCU rcu ; ///< RCU type - one of <tt>cds::urcu::gc< ... ></tt>
typedef NodeType node_type ; ///< Node type
node_type * m_pNode;
//@endcond
- private:
- //@cond
- // No copy-constructible
- exempt_ptr( exempt_ptr const& );
- exempt_ptr& operator=( exempt_ptr const& );
- //@endcond
-
public:
/// Constructs empty pointer
exempt_ptr() CDS_NOEXCEPT
: m_pNode( nullptr )
{}
+ //@cond
+ /// Creates exempt pointer for \p pNode. Only for internal use.
+ explicit exempt_ptr( node_type * pNode ) CDS_NOEXCEPT
+ : m_pNode( pNode )
+ {}
+ explicit exempt_ptr( std::nullptr_t ) CDS_NOEXCEPT
+ : m_pNode( nullptr )
+ {}
+ //@endcond
+
+ /// Move ctor
+ exempt_ptr( exempt_ptr&& p ) CDS_NOEXCEPT
+ : m_pNode( p.m_pNode )
+ {
+ p.m_pNode = nullptr;
+ }
+
+ /// The exempt pointer is not copy-constructible
+ exempt_ptr( exempt_ptr const& ) = delete;
+
/// Releases the pointer
~exempt_ptr()
{
return m_pNode == nullptr;
}
+ /// \p bool operator returns <tt>!empty()</tt>
+ explicit operator bool() const CDS_NOEXCEPT
+ {
+ return !empty();
+ }
+
/// Dereference operator
value_type * operator->() const CDS_NOEXCEPT
{
return *node_to_value_cast()( m_pNode );
}
- //@cond
- /// Assignment operator, the object should be empty. For internal use only
- exempt_ptr& operator =( node_type * pNode )
+ /// Move assignment. Can be called only outside of RCU critical section
+ exempt_ptr& operator =( exempt_ptr&& p ) CDS_NOEXCEPT
{
- // release() cannot be called in this point since RCU should be locked
- assert( empty() );
- assert( rcu::is_locked() );
- m_pNode = pNode;
+ release();
+ m_pNode = p.m_pNode;
+ p.m_pNode = nullptr;
return *this;
}
- //@endcond
+
+ /// The exempt pointer is not copy-assignable
+ exempt_ptr& operator=(exempt_ptr const&) = delete;
/// Disposes the pointer. Should be called only outside of RCU critical section
void release()
>
class exempt_ptr< RCU, NodeType, NodeType, Disposer, void >
{
- //TODO: use move semantics and explicit operator bool!
public:
typedef RCU rcu ; ///< RCU type - one of <tt>cds::urcu::gc< ... ></tt>
typedef NodeType node_type ; ///< Node type
private:
node_type * m_pNode;
- private:
- // No copy-constructible
- exempt_ptr( exempt_ptr const& );
- exempt_ptr& operator=( exempt_ptr const& );
-
public:
/// Constructs empty pointer
exempt_ptr() CDS_NOEXCEPT
: m_pNode( nullptr )
{}
+ /// Creates exempt pointer for \p pNode. Only for internal use.
+ explicit exempt_ptr( node_type * pNode ) CDS_NOEXCEPT
+ : m_pNode( pNode )
+ {}
+ explicit exempt_ptr( std::nullptr_t ) CDS_NOEXCEPT
+ : m_pNode( nullptr )
+ {}
+
+ /// Move ctor
+ exempt_ptr( exempt_ptr&& p ) CDS_NOEXCEPT
+ : m_pNode( p.m_pNode )
+ {
+ p.m_pNode = nullptr;
+ }
+
+
+ /// The exempt pointer is not copy-constructible
+ exempt_ptr( exempt_ptr const& ) = delete;
+
/// Releases the pointer
~exempt_ptr()
{
return m_pNode == nullptr;
}
+ /// \p bool operator returns <tt>!empty()</tt>
+ explicit operator bool() const CDS_NOEXCEPT
+ {
+ return !empty();
+ }
+
/// Dereference operator.
value_type * operator->() const CDS_NOEXCEPT
{
return *m_pNode;
}
- /// Assignment operator, the object should be empty. For internal use only
- exempt_ptr& operator =( node_type * pNode )
+ /// Move assignment. Can be called only outside of RCU critical section
+ exempt_ptr& operator =(exempt_ptr&& p) CDS_NOEXCEPT
{
- // release() cannot be called in this point since RCU should be locked
- assert( empty() );
- assert( rcu::is_locked() );
- m_pNode = pNode;
+ release();
+ m_pNode = p.m_pNode;
+ p.m_pNode = nullptr;
return *this;
}
+ /// The exempt pointer is not copy-assignable
+ exempt_ptr& operator=(exempt_ptr const&) = delete;
+
/// Disposes the pointer. Should be called only outside of RCU critical section
void release()
{
int i = 0;
while ( !m.empty() ) {
- CPPUNIT_ASSERT( m.extract_min( ep ) );
+ ep = m.extract_min();
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_ASSERT(ep->first == i );
++i;
- ep.release();
+ //ep.release();
}
CPPUNIT_ASSERT( m.empty() );
CPPUNIT_ASSERT( check_size( m, 0 ));
- CPPUNIT_ASSERT( !m.extract_min( ep ) );
+ ep = m.extract_min();
+ CPPUNIT_ASSERT( !ep );
CPPUNIT_ASSERT( ep.empty());
fill_map( m, arr );
i = (int) c_nItemCount - 1;
while ( !m.empty() ) {
- CPPUNIT_ASSERT( m.extract_max( ep ) );
+ ep = m.extract_max();
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_ASSERT( ep->first == i );
--i;
- ep.release();
+ //ep.release();
}
CPPUNIT_ASSERT( m.empty() );
CPPUNIT_ASSERT( check_size( m, 0 ));
- CPPUNIT_ASSERT( !m.extract_max( ep ) );
+ ep = m.extract_max();
+ CPPUNIT_ASSERT( !ep );
CPPUNIT_ASSERT( ep.empty());
fill_map( m, arr );
CPPUNIT_ASSERT( pVal != nullptr );
CPPUNIT_CHECK( pVal->first == nKey);
}
- CPPUNIT_ASSERT( m.extract( ep, nKey ));
+ ep = m.extract( nKey );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->first == nKey);
- ep.release();
+ //ep.release();
- CPPUNIT_ASSERT( !m.extract( ep, nKey ));
+ ep = m.extract( nKey );
+ CPPUNIT_ASSERT( !ep );
CPPUNIT_ASSERT( ep.empty());
{
typename map_type::rcu_lock l;
CPPUNIT_ASSERT( pVal != nullptr );
CPPUNIT_CHECK( pVal->first == nKey);
}
- CPPUNIT_ASSERT( m.extract_with( ep, wrapped_int(nKey), wrapped_less() ));
+ ep = m.extract_with( wrapped_int( nKey ), wrapped_less() );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->first == nKey);
- ep.release();
+ //ep.release();
- CPPUNIT_ASSERT( !m.extract_with( ep, wrapped_int(nKey), wrapped_less() ));
+ ep = m.extract_with( wrapped_int( nKey ), wrapped_less() );
+ CPPUNIT_ASSERT( !ep );
CPPUNIT_ASSERT( ep.empty());
{
typename map_type::rcu_lock l;
int i = 0;
value_type v;
while ( !s.empty() ) {
- CPPUNIT_ASSERT( s.extract_min( ep ) );
+ ep = s.extract_min();
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->nKey == i );
++i;
- ep.release();
+ //ep.release();
}
+ ep.release();
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( check_size( s, 0 ));
fill_set( s, arr );
i = (int) c_nItemCount - 1;
while ( !s.empty() ) {
- CPPUNIT_ASSERT( s.extract_max( ep ) );
+ ep = s.extract_max();
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->nKey == i );
--i;
- ep.release();
+ //ep.release();
}
+ ep.release();
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( p != nullptr );
CPPUNIT_CHECK( p->nKey == nKey );
}
- CPPUNIT_ASSERT( s.extract( ep, nKey ));
+ ep = s.extract( nKey );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->nKey == nKey);
- ep.release();
+ //ep.release();
{
typename set_type::rcu_lock l;
CPPUNIT_CHECK( s.get( nKey ) == nullptr );
}
- CPPUNIT_CHECK( !s.extract( ep, nKey ));
+ ep = s.extract( nKey );
+ CPPUNIT_CHECK( !ep );
}
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( p != nullptr );
CPPUNIT_CHECK( p->nKey == nKey );
}
- CPPUNIT_ASSERT( s.extract_with( ep, wrapped_int(nKey), wrapped_less() ));
+ ep = s.extract_with( wrapped_int( nKey ), wrapped_less() );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->nKey == nKey);
- ep.release();
+ //ep.release();
{
typename set_type::rcu_lock l;
CPPUNIT_CHECK( s.get_with( wrapped_int( nKey ), wrapped_less() ) == nullptr );
}
- CPPUNIT_CHECK( !s.extract_with( ep, wrapped_int(nKey), wrapped_less() ));
+ ep = s.extract_with( wrapped_int( nKey ), wrapped_less() );
+ CPPUNIT_CHECK( !ep );
}
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( pVal != nullptr );
CPPUNIT_CHECK( pVal == &v1 );
}
- CPPUNIT_ASSERT( t.extract( ep, v1.nKey ));
+ ep = t.extract( v1.nKey );
CPPUNIT_ASSERT( !ep.empty());
CPPUNIT_CHECK( ep->nKey == v1.nKey );
{
CPPUNIT_CHECK( t.get( v1.nKey ) == nullptr );
}
ep.release();
- CPPUNIT_ASSERT( !t.extract( ep, v1.nKey ));
+ ep = t.extract( v1.nKey );
+ CPPUNIT_ASSERT( ep.empty());
- CPPUNIT_ASSERT( t.extract_min(ep));
+ ep = t.extract_min();
+ CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->nKey == v5.nKey );
{
typename tree_type::rcu_lock l;
CPPUNIT_CHECK( t.get( v5.nKey ) == nullptr );
}
- ep.release();
- CPPUNIT_ASSERT( !t.extract( ep, v5.nKey ));
- CPPUNIT_ASSERT( t.extract_max(ep));
+ ep = t.extract( v5.nKey );
+ CPPUNIT_ASSERT( ep.empty() );
+
+ ep = t.extract_max();
+ CPPUNIT_ASSERT( ep.empty());
CPPUNIT_CHECK( ep->nKey == v3.nKey );
{
typename tree_type::rcu_lock l;
CPPUNIT_ASSERT( pVal != nullptr );
CPPUNIT_CHECK( pVal == &v2 );
}
- CPPUNIT_ASSERT( t.extract_with( ep, wrapped_int(v2.nKey), wrapped_less<value_type>() ));
- CPPUNIT_ASSERT( !ep.empty());
+ ep = t.extract_with( wrapped_int( v2.nKey ), wrapped_less<value_type>() );
+ CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->nKey == v2.nKey );
{
typename tree_type::rcu_lock l;
CPPUNIT_CHECK( t.get_with( wrapped_int( v2.nKey ), wrapped_less<value_type>() ) == nullptr );
}
- ep.release();
- CPPUNIT_CHECK( !t.extract_with( ep, wrapped_int(v2.nKey), wrapped_less<value_type>() ));
+ //ep.release();
+ ep = t.extract_with( wrapped_int( v2.nKey ), wrapped_less<value_type>() );
CPPUNIT_CHECK( ep.empty());
- CPPUNIT_ASSERT( t.extract( ep, v4.nKey ));
- CPPUNIT_ASSERT( !ep.empty());
+ ep = t.extract( v4.nKey );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_CHECK( ep->nKey == v4.nKey );
ep.release();
CPPUNIT_CHECK( t.get( v5.nKey ) == nullptr );
}
- CPPUNIT_CHECK( !t.extract(ep, v1.nKey));
- CPPUNIT_CHECK( !t.extract(ep, v2.nKey));
- CPPUNIT_CHECK( !t.extract(ep, v3.nKey));
- CPPUNIT_CHECK( !t.extract(ep, v4.nKey));
- CPPUNIT_CHECK( !t.extract(ep, v5.nKey));
+ CPPUNIT_CHECK( !t.extract(v1.nKey));
+ CPPUNIT_CHECK( !t.extract(v2.nKey));
+ CPPUNIT_CHECK( !t.extract(v3.nKey));
+ CPPUNIT_CHECK( !t.extract(v4.nKey));
+ CPPUNIT_CHECK( !t.extract(v5.nKey));
tree_type::gc::force_dispose();
}