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

Side by Side Diff: src/untrusted/init/simple_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/scoped_non_ptr.h ('k') | src/untrusted/init/simple_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium 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 LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
6 #define LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
7
8 #include "pthread.h"
9 #include "sdk_util/macros.h"
10
11 namespace sdk_util {
12
13 /*
14 * SimpleLock
15 *
16 * A pthread mutex object, with automatic initialization and destruction.
17 * Should be used with AutoLock where possible.
18 */
19 class SimpleLock {
20 public:
21 SimpleLock() {
22 pthread_mutex_init(&lock_, NULL);
23 }
24
25 ~SimpleLock() {
26 pthread_mutex_destroy(&lock_);
27 }
28
29 void Lock() const { pthread_mutex_lock(&lock_); }
30 void Unlock() const { pthread_mutex_unlock(&lock_); }
31
32 pthread_mutex_t* mutex() const { return &lock_; }
33
34 private:
35 mutable pthread_mutex_t lock_;
36
37 DISALLOW_COPY_AND_ASSIGN(SimpleLock);
38 };
39
40 } // namespace sdk_util
41
42 #endif // LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
OLDNEW
« no previous file with comments | « src/untrusted/init/scoped_non_ptr.h ('k') | src/untrusted/init/simple_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698