diff options
author | deva <deva> | 2005-10-08 15:56:24 +0000 |
---|---|---|
committer | deva <deva> | 2005-10-08 15:56:24 +0000 |
commit | b6a85d646c94f8b1efc51c4a50a644fc902c9521 (patch) | |
tree | 8206479fc2eff08586badcd2ca8b1b766717c3a5 /src/threadsafe_queue_priority.cc | |
parent | 3338a985ce001f4d73aaefa450e008b10496273b (diff) |
*** empty log message ***
Diffstat (limited to 'src/threadsafe_queue_priority.cc')
-rw-r--r-- | src/threadsafe_queue_priority.cc | 24 |
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; |