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

Side by Side Diff: native_client_sdk/src/libraries/gtest_ppapi/thread_condition.h

Issue 10854137: [NaCl SDK] gtest_ppapi library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove hacks Created 8 years, 4 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 THREAD_CONDITION_H_ 5 #ifndef GTEST_PPAPI_THREAD_CONDITION_H_
6 #define THREAD_CONDITION_H_ 6 #define GTEST_PPAPI_THREAD_CONDITION_H_
7 7
8 #include "c_salt/threading/pthread_ext.h" 8 #include "gtest_ppapi/pthread_ext.h"
9 9
10 struct timespec; 10 struct timespec;
11 11
12 namespace c_salt {
13 namespace threading {
14 // A wrapper class for condition signaling. Contains a mutex and condition 12 // A wrapper class for condition signaling. Contains a mutex and condition
15 // pair. 13 // pair.
16 class ThreadCondition { 14 class ThreadCondition {
17 public: 15 public:
18 // Initialize the mutex and the condition. 16 // Initialize the mutex and the condition.
19 ThreadCondition() { 17 ThreadCondition() {
20 pthread_mutex_init(&cond_mutex_, NULL); 18 pthread_mutex_init(&cond_mutex_, NULL);
21 pthread_cond_init(&condition_, NULL); 19 pthread_cond_init(&condition_, NULL);
22 } 20 }
23 21
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Same as Wait, but wait at most until abs_time. Returns false if the system 60 // Same as Wait, but wait at most until abs_time. Returns false if the system
63 // time exceeds abs_time before the condition is signaled. 61 // time exceeds abs_time before the condition is signaled.
64 bool TimedWait(struct timespec *abs_time) { 62 bool TimedWait(struct timespec *abs_time) {
65 return (pthread_cond_timedwait(&condition_, &cond_mutex_, abs_time) == 0); 63 return (pthread_cond_timedwait(&condition_, &cond_mutex_, abs_time) == 0);
66 } 64 }
67 65
68 private: 66 private:
69 pthread_mutex_t cond_mutex_; 67 pthread_mutex_t cond_mutex_;
70 pthread_cond_t condition_; 68 pthread_cond_t condition_;
71 }; 69 };
72 } // namespace threading
73 } // namespace c_salt
74 70
75 #endif // THREAD_CONDITION_H_ 71 #endif // GTEST_PPAPI_THREAD_CONDITION_H_
76
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/gtest_ppapi/scoped_mutex_lock.h ('k') | native_client_sdk/src/libraries/scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698