summaryrefslogtreecommitdiff
path: root/src/threadsafe_queue_fifo.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/threadsafe_queue_fifo.h')
-rw-r--r--src/threadsafe_queue_fifo.h52
1 files changed, 6 insertions, 46 deletions
diff --git a/src/threadsafe_queue_fifo.h b/src/threadsafe_queue_fifo.h
index 404e2f9..9baf82e 100644
--- a/src/threadsafe_queue_fifo.h
+++ b/src/threadsafe_queue_fifo.h
@@ -32,54 +32,14 @@
#include <queue>
template <typename T>
-class ThreadSafeQueueFIFO: ThreadSafeQueue<T> {
+class ThreadSafeQueueFIFO: public ThreadSafeQueue<T> {
public:
- ThreadSafeQueueFIFO() {}
- ~ThreadSafeQueueFIFO() {}
+ ThreadSafeQueueFIFO();
+ ~ThreadSafeQueueFIFO();
- void push(T t) {
- // Lock mutex
- // pthread_mutex_lock( &mutex );
- mutex.lock();
- queue.push(t);
- // pthread_mutex_unlock( &mutex );
- mutex.unlock();
- // Unlock mutex
-
- semaphore.post();
- //sem_post(&semaphore);
- }
-
- T pop() {
- semaphore.wait();
- // sem_wait(&semaphore);
- T t;
-
- // Lock mutex
- // pthread_mutex_lock( &mutex );
- mutex.lock();
- t = queue.front();
- queue.pop();
- // pthread_mutex_unlock( &mutex );
- mutex.unlock();
- // Unlock mutex
-
- return t;
- }
-
- int size() {
- int sz;
-
- // Lock mutex
- // pthread_mutex_lock( &mutex );
- mutex.lock();
- sz = queue.size();
- // pthread_mutex_unlock( &mutex );
- mutex.unlock();
- // Unlock mutex
-
- return sz;
- }
+ void push(T t);
+ T pop();
+ int size();
private:
std::queue<T> queue;