3 #ifndef __CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H
4 #define __CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H
6 #include <cds/container/ellen_bintree_set_hp.h>
7 #include <cds/container/ellen_bintree_set_dhp.h>
8 #include <cds/urcu/general_instant.h>
9 #include <cds/urcu/general_buffered.h>
10 #include <cds/urcu/general_threaded.h>
11 #include <cds/urcu/signal_buffered.h>
12 #include <cds/urcu/signal_threaded.h>
13 #include <cds/container/ellen_bintree_set_rcu.h>
17 template <typename GC>
18 struct EllenBinTreePQueue_pop_max
20 template <typename T, typename Tree>
21 bool operator()( T& dest, Tree& container ) const
23 typename Tree::guarded_ptr gp;
24 bool bRet = container.extract_max( gp );
31 template <typename RCU>
32 struct EllenBinTreePQueue_pop_max< cds::urcu::gc<RCU> >
34 template <typename T, typename Tree>
35 bool operator()( T& dest, Tree& container ) const
37 typename Tree::exempt_ptr ep( container.extract_max());
44 template <typename GC>
45 struct EllenBinTreePQueue_pop_min
47 template <typename T, typename Tree>
48 bool operator()( T& dest, Tree& container ) const
50 typename Tree::guarded_ptr gp;
51 bool bRet = container.extract_min( gp );
58 template <typename RCU>
59 struct EllenBinTreePQueue_pop_min< cds::urcu::gc<RCU> >
61 template <typename T, typename Tree>
62 bool operator()( T& dest, Tree& container ) const
64 typename Tree::exempt_ptr ep( container.extract_min());
71 template <typename GC, typename Key, typename T, typename Traits, bool Max=true>
72 class EllenBinTreePQueue: protected cds::container::EllenBinTreeSet< GC, Key, T, Traits >
74 typedef cds::container::EllenBinTreeSet< GC, Key, T, Traits > base_class;
76 template <typename GC2> friend struct EllenBinTreePQueue_pop_max;
77 template <typename GC2> friend struct EllenBinTreePQueue_pop_min;
80 bool push( value_type const& val )
82 return base_class::insert( val );
85 bool pop( value_type& dest )
87 return Max ? EllenBinTreePQueue_pop_max< typename base_class::gc >()( dest, *this )
88 : EllenBinTreePQueue_pop_min< typename base_class::gc >()( dest, *this );
98 return base_class::empty();
103 return base_class::size();
106 typename base_class::stat const& statistics() const
108 return base_class::statistics();
112 } // namespace pqueue
115 #endif // #ifndef __CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H