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

Side by Side Diff: mojo/edk/system/mutex.h

Issue 1346383004: EDK: Remove MOJO_SYSTEM_IMPL_EXPORT, system_impl_export.h, etc. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/edk/system/message_pipe_endpoint.h ('k') | mojo/edk/system/options_validation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // 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
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A mutex class, with support for thread annotations. 5 // A mutex class, with support for thread annotations.
6 // 6 //
7 // TODO(vtl): Currently, this is a fork of Chromium's 7 // TODO(vtl): Currently, this is a fork of Chromium's
8 // base/synchronization/lock.h (with names changed and minor modifications; it 8 // base/synchronization/lock.h (with names changed and minor modifications; it
9 // still cheats and uses Chromium's lock_impl.*), but eventually we'll want our 9 // still cheats and uses Chromium's lock_impl.*), but eventually we'll want our
10 // own and, e.g., add support for non-exclusive (reader) locks. 10 // own and, e.g., add support for non-exclusive (reader) locks.
11 11
12 #ifndef MOJO_EDK_SYSTEM_MUTEX_H_ 12 #ifndef MOJO_EDK_SYSTEM_MUTEX_H_
13 #define MOJO_EDK_SYSTEM_MUTEX_H_ 13 #define MOJO_EDK_SYSTEM_MUTEX_H_
14 14
15 #include "base/synchronization/lock_impl.h" 15 #include "base/synchronization/lock_impl.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "mojo/edk/system/system_impl_export.h"
18 #include "mojo/edk/system/thread_annotations.h" 17 #include "mojo/edk/system/thread_annotations.h"
19 #include "mojo/public/cpp/system/macros.h" 18 #include "mojo/public/cpp/system/macros.h"
20 19
21 namespace mojo { 20 namespace mojo {
22 namespace system { 21 namespace system {
23 22
24 // Mutex ----------------------------------------------------------------------- 23 // Mutex -----------------------------------------------------------------------
25 24
26 class MOJO_LOCKABLE MOJO_SYSTEM_IMPL_EXPORT Mutex { 25 class MOJO_LOCKABLE Mutex {
27 public: 26 public:
28 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 27 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
29 Mutex() : lock_() {} 28 Mutex() : lock_() {}
30 ~Mutex() {} 29 ~Mutex() {}
31 30
32 void Lock() MOJO_EXCLUSIVE_LOCK_FUNCTION() { lock_.Lock(); } 31 void Lock() MOJO_EXCLUSIVE_LOCK_FUNCTION() { lock_.Lock(); }
33 void Unlock() MOJO_UNLOCK_FUNCTION() { lock_.Unlock(); } 32 void Unlock() MOJO_UNLOCK_FUNCTION() { lock_.Unlock(); }
34 33
35 bool TryLock() MOJO_EXCLUSIVE_TRYLOCK_FUNCTION(true) { return lock_.Try(); } 34 bool TryLock() MOJO_EXCLUSIVE_TRYLOCK_FUNCTION(true) { return lock_.Try(); }
36 35
(...skipping 29 matching lines...) Expand all
66 base::PlatformThreadRef owning_thread_ref_; 65 base::PlatformThreadRef owning_thread_ref_;
67 #endif // !NDEBUG || DCHECK_ALWAYS_ON 66 #endif // !NDEBUG || DCHECK_ALWAYS_ON
68 67
69 base::internal::LockImpl lock_; 68 base::internal::LockImpl lock_;
70 69
71 MOJO_DISALLOW_COPY_AND_ASSIGN(Mutex); 70 MOJO_DISALLOW_COPY_AND_ASSIGN(Mutex);
72 }; 71 };
73 72
74 // MutexLocker ----------------------------------------------------------------- 73 // MutexLocker -----------------------------------------------------------------
75 74
76 class MOJO_SCOPED_LOCKABLE MOJO_SYSTEM_IMPL_EXPORT MutexLocker { 75 class MOJO_SCOPED_LOCKABLE MutexLocker {
77 public: 76 public:
78 explicit MutexLocker(Mutex* mutex) MOJO_EXCLUSIVE_LOCK_FUNCTION(mutex) 77 explicit MutexLocker(Mutex* mutex) MOJO_EXCLUSIVE_LOCK_FUNCTION(mutex)
79 : mutex_(mutex) { 78 : mutex_(mutex) {
80 this->mutex_->Lock(); 79 this->mutex_->Lock();
81 } 80 }
82 ~MutexLocker() MOJO_UNLOCK_FUNCTION() { this->mutex_->Unlock(); } 81 ~MutexLocker() MOJO_UNLOCK_FUNCTION() { this->mutex_->Unlock(); }
83 82
84 private: 83 private:
85 Mutex* const mutex_; 84 Mutex* const mutex_;
86 85
87 MOJO_DISALLOW_COPY_AND_ASSIGN(MutexLocker); 86 MOJO_DISALLOW_COPY_AND_ASSIGN(MutexLocker);
88 }; 87 };
89 88
90 } // namespace system 89 } // namespace system
91 } // namespace mojo 90 } // namespace mojo
92 91
93 #endif // MOJO_EDK_SYSTEM_MUTEX_H_ 92 #endif // MOJO_EDK_SYSTEM_MUTEX_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_endpoint.h ('k') | mojo/edk/system/options_validation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698