11 #include <condition_variable>
20 template<
typename ContentType >
25 std::queue< ContentType > m_queue;
26 std::mutex m_accesslock;
27 std::condition_variable m_condition;
31 void Push (
const ContentType& element );
32 void Push ( ContentType&& element );
33 bool TryPop ( ContentType& element );
34 void Pop ( ContentType& element );
41 template<
typename ContentType >
44 std::lock_guard< std::mutex > guard( m_accesslock );
45 m_queue.push( element );
49 template<
typename ContentType >
50 inline void QueueMT< ContentType >::Push ( ContentType&& element )
52 std::lock_guard< std::mutex > guard( m_accesslock );
53 m_queue.push( std::move( element ) );
58 template<
typename ContentType >
61 std::unique_lock< std::mutex > guard( m_accesslock );
63 while( m_queue.empty() )
65 m_condition.wait( guard );
68 element = std::move( m_queue.front() );
73 template<
typename ContentType >
76 std::unique_lock< std::mutex > guard( m_accesslock );
83 element = std::move( m_queue.front() );
91 template<
typename ContentType >
94 std::lock_guard< std::mutex > guard( m_accesslock );
95 return m_queue.empty();
bool IsEmpty()
Zwraca true, jeżeli kolejka jest pusta. Należy pamiętać, że po wywołaniu tej funkcji kolejka może zos...
Definition: QueueMT.h:92
Definition: Exception.h:11
void Pop(ContentType &element)
Returns element in parameter.
Definition: QueueMT.h:59
Concurrent queue.
Definition: QueueMT.h:21