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

Side by Side Diff: native_client_sdk/src/libraries/sdk_util/simple_lock.h

Issue 18644009: [NaCl SDK] Upate atomic ops in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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
6 #ifndef LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
7 #define LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
8
9 #include "pthread.h"
10 #include "sdk_util/macros.h"
11
12 class AutoLock;
binji 2013/07/12 00:51:23 not necessary
noelallen1 2013/07/12 23:18:47 Done.
13
14 /*
15 * SimpleLock
16 *
17 * A pthread mutex object, with automatic initialization and destruction.
18 * Should be used with AutoLock where possible.
19 */
20 class SimpleLock {
binji 2013/07/12 00:51:23 Why SimpleLock? Maybe just Lock?
noelallen1 2013/07/12 23:18:47 Less likely to collide with a name.
binji 2013/07/13 00:16:47 OK, can we change it to Lock after I add namespace
21 public:
22 SimpleLock() {
23 pthread_mutex_init(&lock_, NULL);
24 }
25
26 ~SimpleLock() {
27 pthread_mutex_destroy(&lock_);
28 }
29
30 operator pthread_mutex_t*() const { return &lock_; }
binji 2013/07/12 00:51:23 We should just have a function for this, rather th
noelallen1 2013/07/12 23:18:47 Done.
31
32 private:
33 mutable pthread_mutex_t lock_;
34 friend class AutoLock;
35
36 DISALLOW_COPY_AND_ASSIGN(SimpleLock);
37 };
38
39 #endif // LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
40
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698