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

Side by Side Diff: experimental/conways_life/threading/scoped_mutex_lock.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SCOPED_MUTEX_LOCK_H_
6 #define SCOPED_MUTEX_LOCK_H_
7
8 #include "experimental/conways_life/threading/pthread_ext.h"
9
10 namespace threading {
11 // A small helper RAII class that implements a scoped pthread_mutex lock.
12 class ScopedMutexLock {
13 public:
14 explicit ScopedMutexLock(pthread_mutex_t* mutex) : mutex_(mutex) {
15 if (pthread_mutex_lock(mutex_) != PTHREAD_MUTEX_SUCCESS) {
16 mutex_ = NULL;
17 }
18 }
19 ~ScopedMutexLock() {
20 if (mutex_)
21 pthread_mutex_unlock(mutex_);
22 }
23 bool is_valid() const {
24 return mutex_ != NULL;
25 }
26 private:
27 pthread_mutex_t* mutex_; // Weak reference.
28 };
29 } // namespace threading
30
31 #endif // SCOPED_MUTEX_LOCK_H_
32
OLDNEW
« no previous file with comments | « experimental/conways_life/threading/ref_count.h ('k') | experimental/conways_life/threading/thread_condition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698