summaryrefslogtreecommitdiff
path: root/src/threadsafe_queue_fifo.h
diff options
context:
space:
mode:
authordeva <deva>2005-10-08 15:56:24 +0000
committerdeva <deva>2005-10-08 15:56:24 +0000
commitb6a85d646c94f8b1efc51c4a50a644fc902c9521 (patch)
tree8206479fc2eff08586badcd2ca8b1b766717c3a5 /src/threadsafe_queue_fifo.h
parent3338a985ce001f4d73aaefa450e008b10496273b (diff)
*** empty log message ***
Diffstat (limited to 'src/threadsafe_queue_fifo.h')
-rw-r--r--src/threadsafe_queue_fifo.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/threadsafe_queue_fifo.h b/src/threadsafe_queue_fifo.h
index 30f6645..404e2f9 100644
--- a/src/threadsafe_queue_fifo.h
+++ b/src/threadsafe_queue_fifo.h
@@ -32,30 +32,36 @@
#include <queue>
template <typename T>
-class ThreadSafeQueueFIFO: public ThreadSafeQueue<T> {
+class ThreadSafeQueueFIFO: ThreadSafeQueue<T> {
public:
ThreadSafeQueueFIFO() {}
~ThreadSafeQueueFIFO() {}
void push(T t) {
// Lock mutex
- pthread_mutex_lock( &mutex );
+ // pthread_mutex_lock( &mutex );
+ mutex.lock();
queue.push(t);
- pthread_mutex_unlock( &mutex );
+ // pthread_mutex_unlock( &mutex );
+ mutex.unlock();
// Unlock mutex
- sem_post(&semaphore);
+ semaphore.post();
+ //sem_post(&semaphore);
}
T pop() {
- sem_wait(&semaphore);
+ semaphore.wait();
+ // sem_wait(&semaphore);
T t;
// Lock mutex
- pthread_mutex_lock( &mutex );
+ // pthread_mutex_lock( &mutex );
+ mutex.lock();
t = queue.front();
queue.pop();
- pthread_mutex_unlock( &mutex );
+ // pthread_mutex_unlock( &mutex );
+ mutex.unlock();
// Unlock mutex
return t;
@@ -65,9 +71,11 @@ public:
int sz;
// Lock mutex
- pthread_mutex_lock( &mutex );
+ // pthread_mutex_lock( &mutex );
+ mutex.lock();
sz = queue.size();
- pthread_mutex_unlock( &mutex );
+ // pthread_mutex_unlock( &mutex );
+ mutex.unlock();
// Unlock mutex
return sz;