| Index: native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h
|
| diff --git a/native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h b/native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h
|
| index 545b7c4589f6eadcb90ea9238e134d4d717549ff..5dad02874774fd43b63939418130ba7fa7957df6 100644
|
| --- a/native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h
|
| +++ b/native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h
|
| @@ -21,28 +21,26 @@
|
| template<class T> class ThreadSafeQueue {
|
| public:
|
| ThreadSafeQueue() {
|
| - pthread_mutex_init(&mutex_, NULL);
|
| pthread_cond_init(&cond_, NULL);
|
| }
|
|
|
| ~ThreadSafeQueue() {
|
| - pthread_mutex_destroy(&mutex_);
|
| pthread_cond_destroy(&cond_);
|
| }
|
|
|
| void Enqueue(T* item) {
|
| - AutoLock lock(&mutex_);
|
| + AUTO_LOCK(lock_);
|
| list_.push_back(item);
|
|
|
| pthread_cond_signal(&cond_);
|
| }
|
|
|
| T* Dequeue(bool block) {
|
| - AutoLock lock(&mutex_);
|
| + AUTO_LOCK(lock_);
|
|
|
| // If blocking enabled, wait until we queue is non-empty
|
| if (block) {
|
| - while (list_.empty()) pthread_cond_wait(&cond_, &mutex_);
|
| + while (list_.empty()) pthread_cond_wait(&cond_, lock_.mutex());
|
| }
|
|
|
| if (list_.empty()) return NULL;
|
| @@ -55,7 +53,7 @@ template<class T> class ThreadSafeQueue {
|
| private:
|
| std::list<T*> list_;
|
| pthread_cond_t cond_;
|
| - pthread_mutex_t mutex_;
|
| + SimpleLock lock_;
|
| DISALLOW_COPY_AND_ASSIGN(ThreadSafeQueue);
|
| };
|
|
|
|
|