3 #ifndef __CDSUNIT_STD_PQUEUE_H
4 #define __CDSUNIT_STD_PQUEUE_H
12 template <typename T, typename Container, typename Lock, typename Less=std::less<typename Container::value_type> >
16 typedef std::priority_queue<value_type, Container, Less> pqueue_type;
25 scoped_lock( Lock& l )
38 bool push( value_type const& val )
40 scoped_lock l( m_Lock );
45 bool pop( value_type& dest )
47 scoped_lock l( m_Lock );
48 if ( !m_PQueue.empty() ) {
49 dest = m_PQueue.top();
56 template <typename Q, typename MoveFunc>
57 bool pop_with( Q& dest, MoveFunc f )
59 scoped_lock l( m_Lock );
60 if ( !m_PQueue.empty() ) {
61 f( dest, m_PQueue.top());
70 scoped_lock l( m_Lock );
71 while ( !m_PQueue.empty() )
75 template <typename Func>
76 void clear_with( Func f )
78 scoped_lock l( m_Lock );
79 while ( !m_PQueue.empty() ) {
87 return m_PQueue.empty();
92 return m_PQueue.size();
95 dummy_stat statistics() const
101 } // namespace pqueue
104 static inline ostream& operator <<( ostream& o, pqueue::dummy_stat )
110 #endif // #ifndef __CDSUNIT_STD_PQUEUE_H