| OLD | NEW |
| 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_ |
| OLD | NEW |