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( container.extract_max());
30 template <typename RCU>
31 struct EllenBinTreePQueue_pop_max< cds::urcu::gc<RCU> >
33 template <typename T, typename Tree>
34 bool operator()( T& dest, Tree& container ) const
36 typename Tree::exempt_ptr ep( container.extract_max());
43 template <typename GC>
44 struct EllenBinTreePQueue_pop_min
46 template <typename T, typename Tree>
47 bool operator()( T& dest, Tree& container ) const
49 typename Tree::guarded_ptr gp( container.extract_min());
56 template <typename RCU>
57 struct EllenBinTreePQueue_pop_min< cds::urcu::gc<RCU> >
59 template <typename T, typename Tree>
60 bool operator()( T& dest, Tree& container ) const
62 typename Tree::exempt_ptr ep( container.extract_min());
69 template <typename GC, typename Key, typename T, typename Traits, bool Max=true>
70 class EllenBinTreePQueue: protected cds::container::EllenBinTreeSet< GC, Key, T, Traits >
72 typedef cds::container::EllenBinTreeSet< GC, Key, T, Traits > base_class;
74 template <typename GC2> friend struct EllenBinTreePQueue_pop_max;
75 template <typename GC2> friend struct EllenBinTreePQueue_pop_min;
78 bool push( value_type const& val )
80 return base_class::insert( val );
83 bool pop( value_type& dest )
85 return Max ? EllenBinTreePQueue_pop_max< typename base_class::gc >()( dest, *this )
86 : EllenBinTreePQueue_pop_min< typename base_class::gc >()( dest, *this );
96 return base_class::empty();
101 return base_class::size();
104 typename base_class::stat const& statistics() const
106 return base_class::statistics();
110 } // namespace pqueue
113 #endif // #ifndef __CDSUNIT_STD_ELLEN_BINTREE_PQUEUE_H