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

Side by Side Diff: native_client_sdk/src/examples/api/input_event/shared_queue.h

Issue 14607005: [NaCl SDK] Cleanup examples. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 SHARED_QUEUE_H 5 #ifndef SHARED_QUEUE_H
6 #define SHARED_QUEUE_H 6 #define SHARED_QUEUE_H
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <cassert> 9 #include <cassert>
10 #include <deque> 10 #include <deque>
11 11
12 namespace event_queue {
13
14 // This file provides a queue that uses a mutex and condition variable so that 12 // This file provides a queue that uses a mutex and condition variable so that
15 // one thread can put pointers into the queue and another thread can pull items 13 // one thread can put pointers into the queue and another thread can pull items
16 // out of the queue. 14 // out of the queue.
17 15
18 // Specifies whether we want to wait for the queue. 16 // Specifies whether we want to wait for the queue.
19 enum QueueWaitingFlag { 17 enum QueueWaitingFlag {
20 kWait = 0, 18 kWait = 0,
21 kDontWait 19 kDontWait
22 }; 20 };
23 21
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 private: 137 private:
140 std::deque<T> the_queue_; 138 std::deque<T> the_queue_;
141 bool quit_; 139 bool quit_;
142 pthread_mutex_t queue_mutex_; 140 pthread_mutex_t queue_mutex_;
143 pthread_cond_t queue_condition_var_; 141 pthread_cond_t queue_condition_var_;
144 142
145 // This is used by methods that already have the lock. 143 // This is used by methods that already have the lock.
146 bool is_empty_no_locking() const { return the_queue_.empty(); } 144 bool is_empty_no_locking() const { return the_queue_.empty(); }
147 }; 145 };
148 146
149 } // end of unnamed namespace
150
151 #endif // SHARED_QUEUE_H 147 #endif // SHARED_QUEUE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698