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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/sdk_util/auto_lock.h
===================================================================
--- native_client_sdk/src/libraries/sdk_util/auto_lock.h (revision 0)
+++ native_client_sdk/src/libraries/sdk_util/auto_lock.h (revision 0)
@@ -0,0 +1,31 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
+#define LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
+
+#include <pthread.h>
+
+class AutoLock {
+ public:
+ explicit AutoLock(pthread_mutex_t* lock) {
+ lock_ = lock;
+ pthread_mutex_lock(lock_);
+ }
+ ~AutoLock() {
+ if (lock_) pthread_mutex_unlock(lock_);
+ }
+
+ void Unlock() {
+ if (lock_) pthread_mutex_unlock(lock_);
+ lock_ = NULL;
+ }
+
+ private:
+ pthread_mutex_t* lock_;
+};
+
+#endif // LIBRARIES_SDK_UTIL_AUTO_LOCK_H_
+
Property changes on: native_client_sdk/src/libraries/sdk_util/auto_lock.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps_instance.h ('k') | native_client_sdk/src/libraries/sdk_util/library.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698