3 #ifndef __CDSUNIT_SKIPLIST_PQUEUE_H
4 #define __CDSUNIT_SKIPLIST_PQUEUE_H
6 #include <cds/container/skip_list_set_hp.h>
7 #include <cds/container/skip_list_set_hrc.h>
8 #include <cds/container/skip_list_set_ptb.h>
9 #include <cds/urcu/general_instant.h>
10 #include <cds/urcu/general_buffered.h>
11 #include <cds/urcu/general_threaded.h>
12 #include <cds/urcu/signal_buffered.h>
13 #include <cds/urcu/signal_threaded.h>
14 #include <cds/container/skip_list_set_rcu.h>
18 template <typename GC>
19 struct SkipListPQueue_pop_max
21 template <typename T, typename Set>
22 bool operator()( T& dest, Set& container ) const
24 typename Set::guarded_ptr gp;
25 bool bRet = container.extract_max( gp );
32 template <typename RCU>
33 struct SkipListPQueue_pop_max< cds::urcu::gc<RCU> >
35 template <typename T, typename Set>
36 bool operator()( T& dest, Set& container ) const
38 typename Set::exempt_ptr ep;
39 bool bRet = container.extract_max( ep );
46 template <typename GC>
47 struct SkipListPQueue_pop_min
49 template <typename T, typename Set>
50 bool operator()( T& dest, Set& container ) const
52 typename Set::guarded_ptr gp;
53 bool bRet = container.extract_min( gp );
60 template <typename RCU>
61 struct SkipListPQueue_pop_min< cds::urcu::gc<RCU> >
63 template <typename T, typename Set>
64 bool operator()( T& dest, Set& container ) const
66 typename Set::exempt_ptr ep;
67 bool bRet = container.extract_min( ep );
74 template <typename GC, typename T, typename Traits, bool Max=true>
75 class SkipListPQueue: protected cds::container::SkipListSet< GC, T, Traits >
77 typedef cds::container::SkipListSet< GC, T, Traits > base_class;
79 template <typename GC2> friend struct SkipListPQueue_pop_max;
80 template <typename GC2> friend struct SkipListPQueue_pop_min;
83 bool push( value_type const& val )
85 return base_class::insert( val );
88 bool pop( value_type& dest )
90 return Max ? SkipListPQueue_pop_max< typename base_class::gc >()( dest, *this )
91 : SkipListPQueue_pop_min< typename base_class::gc >()( dest, *this );
101 return base_class::empty();
106 return base_class::size();
109 typename base_class::stat const& statistics() const
111 return base_class::statistics();
115 } // namespace pqueue
117 #endif // #ifndef __CDSUNIT_SKIPLIST_PQUEUE_H