From b6a85d646c94f8b1efc51c4a50a644fc902c9521 Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 8 Oct 2005 15:56:24 +0000 Subject: *** empty log message *** --- src/threadsafe_queue_priority.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/threadsafe_queue_priority.cc') diff --git a/src/threadsafe_queue_priority.cc b/src/threadsafe_queue_priority.cc index 130b0f5..df7ae8c 100644 --- a/src/threadsafe_queue_priority.cc +++ b/src/threadsafe_queue_priority.cc @@ -43,24 +43,29 @@ ThreadSafeQueuePriority::~ThreadSafeQueuePriority() void ThreadSafeQueuePriority::push(Frame *frame) { // Lock mutex - pthread_mutex_lock( &mutex ); + // pthread_mutex_lock( &mutex ); + mutex.lock(); queue.push(frame); - pthread_mutex_unlock( &mutex ); + // pthread_mutex_unlock( &mutex ); + mutex.unlock(); // Unlock mutex - sem_post(&semaphore); + // sem_post(&semaphore); + semaphore.post(); } Frame *ThreadSafeQueuePriority::pop() { - sem_wait(&semaphore); + semaphore.wait(); + // sem_wait(&semaphore); Frame *tmpframe = NULL; Frame *frame = NULL; while( frame == NULL ) { // Lock mutex - pthread_mutex_lock( &mutex ); + // pthread_mutex_lock( &mutex ); + mutex.lock(); tmpframe = queue.top(); @@ -70,7 +75,8 @@ Frame *ThreadSafeQueuePriority::pop() framenumber++; } - pthread_mutex_unlock( &mutex ); + // pthread_mutex_unlock( &mutex ); + mutex.unlock(); // Unlock mutex if(frame == NULL) sleep_0_2_frame(); @@ -84,9 +90,11 @@ int ThreadSafeQueuePriority::size() 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; -- cgit v1.2.3