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_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/skip_list_set_rcu.h>
17 template <typename GC>
18 struct SkipListPQueue_pop_max
20 template <typename T, typename Set>
21 bool operator()( T& dest, Set& container ) const
23 typename Set::guarded_ptr gp;
24 bool bRet = container.extract_max( gp );
31 template <typename RCU>
32 struct SkipListPQueue_pop_max< cds::urcu::gc<RCU> >
34 template <typename T, typename Set>
35 bool operator()( T& dest, Set& container ) const
37 typename Set::exempt_ptr ep;
38 bool bRet = container.extract_max( ep );
45 template <typename GC>
46 struct SkipListPQueue_pop_min
48 template <typename T, typename Set>
49 bool operator()( T& dest, Set& container ) const
51 typename Set::guarded_ptr gp;
52 bool bRet = container.extract_min( gp );
59 template <typename RCU>
60 struct SkipListPQueue_pop_min< cds::urcu::gc<RCU> >
62 template <typename T, typename Set>
63 bool operator()( T& dest, Set& container ) const
65 typename Set::exempt_ptr ep;
66 bool bRet = container.extract_min( ep );
73 template <typename GC, typename T, typename Traits, bool Max=true>
74 class SkipListPQueue: protected cds::container::SkipListSet< GC, T, Traits >
76 typedef cds::container::SkipListSet< GC, T, Traits > base_class;
78 template <typename GC2> friend struct SkipListPQueue_pop_max;
79 template <typename GC2> friend struct SkipListPQueue_pop_min;
82 bool push( value_type const& val )
84 return base_class::insert( val );
87 bool pop( value_type& dest )
89 return Max ? SkipListPQueue_pop_max< typename base_class::gc >()( dest, *this )
90 : SkipListPQueue_pop_min< typename base_class::gc >()( dest, *this );
100 return base_class::empty();
105 return base_class::size();
108 typename base_class::stat const& statistics() const
110 return base_class::statistics();
114 } // namespace pqueue
116 #endif // #ifndef __CDSUNIT_SKIPLIST_PQUEUE_H