OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef LIBRARIES_UTILS_THREAD_SAFE_QUEUE_H_ | 5 #ifndef LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_ |
6 #define LIBRARIES_UTILS_THREAD_SAFE_QUEUE_H_ | 6 #define LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_ |
7 | 7 |
8 #include <pthread.h> | 8 #include <pthread.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 | 11 |
12 #include "utils/auto_lock.h" | 12 #include "sdk_util/auto_lock.h" |
13 #include "utils/macros.h" | 13 #include "sdk_util/macros.h" |
14 | 14 |
15 | 15 |
16 // ThreadSafeQueue | 16 // ThreadSafeQueue |
17 // | 17 // |
18 // A simple template to support multithreaded and optionally blocking access | 18 // A simple template to support multithreaded and optionally blocking access |
19 // to a Queue of object pointers. | 19 // to a Queue of object pointers. |
20 // | 20 // |
21 template<class T> class ThreadSafeQueue { | 21 template<class T> class ThreadSafeQueue { |
22 public: | 22 public: |
23 ThreadSafeQueue() { | 23 ThreadSafeQueue() { |
(...skipping 28 matching lines...) Expand all Loading... |
52 return item; | 52 return item; |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 std::list<T*> list_; | 56 std::list<T*> list_; |
57 pthread_cond_t cond_; | 57 pthread_cond_t cond_; |
58 pthread_mutex_t mutex_; | 58 pthread_mutex_t mutex_; |
59 DISALLOW_COPY_AND_ASSIGN(ThreadSafeQueue); | 59 DISALLOW_COPY_AND_ASSIGN(ThreadSafeQueue); |
60 }; | 60 }; |
61 | 61 |
62 #endif // LIBRARIES_UTILS_THREAD_SAFE_QUEUE_H_ | 62 #endif // LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_ |
| 63 |
OLD | NEW |