summaryrefslogtreecommitdiff
path: root/src/threadsafe_queue_priority.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/threadsafe_queue_priority.cc')
-rw-r--r--src/threadsafe_queue_priority.cc24
1 files changed, 16 insertions, 8 deletions
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;