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

Unified Diff: mojo/edk/system/mutex.h

Issue 1426343002: EDK: Move mutex.*, cond_var.*, and thread_annotations.h to //mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/mutex.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/mutex.h
diff --git a/mojo/edk/system/mutex.h b/mojo/edk/system/mutex.h
deleted file mode 100644
index 0ce1ed396c6a237075cb2db7d76cecdcc807ef58..0000000000000000000000000000000000000000
--- a/mojo/edk/system/mutex.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// A mutex class, with support for thread annotations.
-//
-// TODO(vtl): Add support for non-exclusive (reader) locks.
-
-#ifndef MOJO_EDK_SYSTEM_MUTEX_H_
-#define MOJO_EDK_SYSTEM_MUTEX_H_
-
-#include <pthread.h>
-
-#include "mojo/edk/system/thread_annotations.h"
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-namespace system {
-
-// So |Mutex| can friend it.
-class CondVar;
-
-// Mutex -----------------------------------------------------------------------
-
-class MOJO_LOCKABLE Mutex {
- public:
-#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
- Mutex() { pthread_mutex_init(&impl_, nullptr); }
- ~Mutex() { pthread_mutex_destroy(&impl_); }
-
- // Takes an exclusive lock.
- void Lock() MOJO_EXCLUSIVE_LOCK_FUNCTION() { pthread_mutex_lock(&impl_); }
-
- // Releases a lock.
- void Unlock() MOJO_UNLOCK_FUNCTION() { pthread_mutex_unlock(&impl_); }
-
- // Tries to take an exclusive lock, returning true if successful.
- bool TryLock() MOJO_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
- return !pthread_mutex_trylock(&impl_);
- }
-
- // Asserts that an exclusive lock is held by the calling thread. (Does nothing
- // for non-Debug builds.)
- void AssertHeld() MOJO_ASSERT_EXCLUSIVE_LOCK() {}
-#else
- Mutex();
- ~Mutex();
-
- void Lock() MOJO_EXCLUSIVE_LOCK_FUNCTION();
- void Unlock() MOJO_UNLOCK_FUNCTION();
-
- bool TryLock() MOJO_EXCLUSIVE_TRYLOCK_FUNCTION(true);
-
- void AssertHeld() MOJO_ASSERT_EXCLUSIVE_LOCK();
-#endif // defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
-
- private:
- friend class CondVar;
-
- pthread_mutex_t impl_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(Mutex);
-};
-
-// MutexLocker -----------------------------------------------------------------
-
-class MOJO_SCOPED_LOCKABLE MutexLocker {
- public:
- explicit MutexLocker(Mutex* mutex) MOJO_EXCLUSIVE_LOCK_FUNCTION(mutex)
- : mutex_(mutex) {
- this->mutex_->Lock();
- }
- ~MutexLocker() MOJO_UNLOCK_FUNCTION() { this->mutex_->Unlock(); }
-
- private:
- Mutex* const mutex_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(MutexLocker);
-};
-
-} // namespace system
-} // namespace mojo
-
-#endif // MOJO_EDK_SYSTEM_MUTEX_H_
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/mutex.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698