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

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

Issue 16325024: Move thread_pool.h into utils so it can be shared by more than one example. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 5
6 #ifndef LIBRARIES_UTILS_AUTO_LOCK_H_ 6 #ifndef LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
7 #define LIBRARIES_UTILS_AUTO_LOCK_H_ 7 #define LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
8 8
9 #include <pthread.h> 9 #include <pthread.h>
10 10
11 class AutoLock { 11 class AutoLock {
12 public: 12 public:
13 explicit AutoLock(pthread_mutex_t* lock) { 13 explicit AutoLock(pthread_mutex_t* lock) {
14 lock_ = lock; 14 lock_ = lock;
15 pthread_mutex_lock(lock_); 15 pthread_mutex_lock(lock_);
16 } 16 }
17 ~AutoLock() { 17 ~AutoLock() {
18 if (lock_) pthread_mutex_unlock(lock_); 18 if (lock_) pthread_mutex_unlock(lock_);
19 } 19 }
20 20
21 void Unlock() { 21 void Unlock() {
22 if (lock_) pthread_mutex_unlock(lock_); 22 if (lock_) pthread_mutex_unlock(lock_);
23 lock_ = NULL; 23 lock_ = NULL;
24 } 24 }
25 25
26 private: 26 private:
27 pthread_mutex_t* lock_; 27 pthread_mutex_t* lock_;
28 }; 28 };
29 29
30 #endif // LIBRARIES_UTILS_AUTO_LOCK_H_ 30 #endif // LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
31
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698