From 48775e1ce9eb0dd53908110454d068a8b16a66ec Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 8 Oct 2005 16:07:50 +0000 Subject: *** empty log message *** --- src/threadsafe_queue_fifo.cc | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/threadsafe_queue_fifo.cc') diff --git a/src/threadsafe_queue_fifo.cc b/src/threadsafe_queue_fifo.cc index 633cb58..50c1067 100644 --- a/src/threadsafe_queue_fifo.cc +++ b/src/threadsafe_queue_fifo.cc @@ -26,10 +26,9 @@ */ #include "config.h" #include "threadsafe_queue_fifo.h" -/* + template ThreadSafeQueueFIFO::ThreadSafeQueueFIFO() - // : ThreadSafeQueue() { } @@ -41,29 +40,25 @@ ThreadSafeQueueFIFO::~ThreadSafeQueueFIFO() template void ThreadSafeQueueFIFO::push(T t) { - // Lock mutex - pthread_mutex_lock( &mutex ); + mutex.lock(); queue.push(t); - pthread_mutex_unlock( &mutex ); - // Unlock mutex - - sem_post(&semaphore); + mutex.unlock(); + + semaphore.post(); } template T ThreadSafeQueueFIFO::pop() { - sem_wait(&semaphore); - + semaphore.wait(); + T t; - - // Lock mutex - pthread_mutex_lock( &mutex ); + + mutex.lock(); t = queue.front(); queue.pop(); - pthread_mutex_unlock( &mutex ); - // Unlock mutex - + mutex.unlock(); + return t; } @@ -71,13 +66,10 @@ template int ThreadSafeQueueFIFO::size() { int sz; - - // Lock mutex - pthread_mutex_lock( &mutex ); + + mutex.lock(); sz = queue.size(); - pthread_mutex_unlock( &mutex ); - // Unlock mutex - + mutex.unlock(); + return sz; } -*/ -- cgit v1.2.3