Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h

Issue 19717004: [NaCl SDK] Add nacl_io and sdk_util namespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad copyright in mount_mem Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/src/libraries/sdk_util/thread_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SDK_UTIL_THREAD_SAFE_QUEUE_H_ 5 #ifndef LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_
6 #define LIBRARIES_SDK_UTIL_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 "sdk_util/auto_lock.h" 12 #include "sdk_util/auto_lock.h"
13 #include "sdk_util/macros.h" 13 #include "sdk_util/macros.h"
14 14
15 namespace sdk_util {
15 16
16 // ThreadSafeQueue 17 // ThreadSafeQueue
17 // 18 //
18 // A simple template to support multithreaded and optionally blocking access 19 // A simple template to support multithreaded and optionally blocking access
19 // to a Queue of object pointers. 20 // to a Queue of object pointers.
20 // 21 //
21 template<class T> class ThreadSafeQueue { 22 template<class T> class ThreadSafeQueue {
22 public: 23 public:
23 ThreadSafeQueue() { 24 ThreadSafeQueue() {
24 pthread_cond_init(&cond_, NULL); 25 pthread_cond_init(&cond_, NULL);
(...skipping 25 matching lines...) Expand all
50 return item; 51 return item;
51 } 52 }
52 53
53 private: 54 private:
54 std::list<T*> list_; 55 std::list<T*> list_;
55 pthread_cond_t cond_; 56 pthread_cond_t cond_;
56 SimpleLock lock_; 57 SimpleLock lock_;
57 DISALLOW_COPY_AND_ASSIGN(ThreadSafeQueue); 58 DISALLOW_COPY_AND_ASSIGN(ThreadSafeQueue);
58 }; 59 };
59 60
61 } // namespace sdk_util
62
60 #endif // LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_ 63 #endif // LIBRARIES_SDK_UTIL_THREAD_SAFE_QUEUE_H_
61 64
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/sdk_util/thread_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698