12 MPMCQueue<T>::MPMCQueue()
14 pthread_mutex_init(&m_mutex, 0);
18 MPMCQueue<T>::~MPMCQueue()
20 pthread_mutex_destroy(&m_mutex);
24 size_t MPMCQueue<T>::Size()
const
27 pthread_mutex_lock(&m_mutex);
28 size = m_queue.size();
29 pthread_mutex_unlock(&m_mutex);
34 void MPMCQueue<T>::Enqueue(T message)
36 pthread_mutex_lock(&m_mutex);
37 m_queue.push_back(message);
38 pthread_mutex_unlock(&m_mutex);
43 void MPMCQueue<T>::EnqueueHead(T message)
45 pthread_mutex_lock(&m_mutex);
46 m_queue.push_front(message);
47 pthread_mutex_unlock(&m_mutex);
52 T MPMCQueue<T>::Dequeue()
55 return DequeueMessageFromHead();
59 bool MPMCQueue<T>::TryDequeue(T& message)
61 if (m_signal.TryWait())
63 message = DequeueMessageFromHead();
70 T MPMCQueue<T>::DequeueMessageFromHead()
72 pthread_mutex_lock(&m_mutex);
73 Eegeo_ASSERT(m_queue.size() > 0,
"No message to deqeue");
74 T message = m_queue.front();
76 pthread_mutex_unlock(&m_mutex);