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

Side by Side Diff: src/untrusted/init/scoped_lock.h

Issue 25147002: nacl_init Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 2 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 | « src/untrusted/init/process_lib.cc ('k') | src/untrusted/init/scoped_non_ptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // -*- c++ -*-
2 // Copyright (c) 2013 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 // 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
4 // found in the LICENSE file. 3 // found in the LICENSE file.
5 4
6 #ifndef NATIVE_CLIENT_TESTS_SUBPROCESS_SCOPED_LOCK_H_ 5 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_INIT_SCOPED_LOCK_H_
7 6
8 #include <pthread.h> 7 #include <pthread.h>
9 8
10 // no name space, since this is so common 9 class ScopedLock {
11 class MutexLocker {
12 public: 10 public:
13 explicit MutexLocker(pthread_mutex_t *lock) 11 explicit ScopedLock(pthread_mutex_t *lock)
14 : lock_(lock) { 12 : lock_(lock) {
15 pthread_mutex_lock(lock_); 13 pthread_mutex_lock(lock_);
16 } 14 }
17 ~MutexLocker() { 15 ~ScopedLock() {
18 pthread_mutex_unlock(lock_); 16 pthread_mutex_unlock(lock_);
19 } 17 }
20 private: 18 private:
21 pthread_mutex_t *lock_; 19 pthread_mutex_t *lock_;
22 }; 20 };
23 21
24 #endif // NATIVE_CLIENT_TESTS_SUBPROCESS_SCOPED_LOCK_H_ 22 #endif // NATIVE_CLIENT_SRC_UNTRUSTED_INIT_SCOPED_LOCK_H_
OLDNEW
« no previous file with comments | « src/untrusted/init/process_lib.cc ('k') | src/untrusted/init/scoped_non_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698