Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / native_client_sdk / src / libraries / sdk_util / simple_lock.h
blob1f3818511dd806c56673ad067dd867a35b226dfd
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.
5 #ifndef LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
6 #define LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_
8 #include "pthread.h"
9 #include "sdk_util/macros.h"
11 namespace sdk_util {
14 * SimpleLock
16 * A pthread mutex object, with automatic initialization and destruction.
17 * Should be used with AutoLock where possible.
19 class SimpleLock {
20 public:
21 SimpleLock() {
22 pthread_mutex_init(&lock_, NULL);
25 ~SimpleLock() {
26 pthread_mutex_destroy(&lock_);
29 void Lock() const { pthread_mutex_lock(&lock_); }
30 void Unlock() const { pthread_mutex_unlock(&lock_); }
32 pthread_mutex_t* mutex() const { return &lock_; }
34 private:
35 mutable pthread_mutex_t lock_;
37 DISALLOW_COPY_AND_ASSIGN(SimpleLock);
40 } // namespace sdk_util
42 #endif // LIBRARIES_SDK_UTIL_SIMPLE_LOCK_H_