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

Unified Diff: mojo/edk/util/mutex.cc

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/util/mutex.h ('k') | mojo/edk/util/mutex_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/util/mutex.cc
diff --git a/mojo/edk/system/mutex.cc b/mojo/edk/util/mutex.cc
similarity index 57%
rename from mojo/edk/system/mutex.cc
rename to mojo/edk/util/mutex.cc
index 45f4389b923a6e4a9577b38214496070696b1aed..1f006df5beab22c1343e11ff16c45a8a1cff8651 100644
--- a/mojo/edk/system/mutex.cc
+++ b/mojo/edk/util/mutex.cc
@@ -2,57 +2,56 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/edk/system/mutex.h"
+#include "mojo/edk/util/mutex.h"
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#include <errno.h>
-#include <string.h>
-#include "base/logging.h"
+#include "mojo/edk/util/logging_internal.h"
namespace mojo {
-namespace system {
+namespace util {
Mutex::Mutex() {
pthread_mutexattr_t attr;
int error = pthread_mutexattr_init(&attr);
- DCHECK(!error) << "pthread_mutexattr_init: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutexattr_init", error);
error = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
- DCHECK(!error) << "pthread_mutexattr_settype: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutexattr_settype", error);
error = pthread_mutex_init(&impl_, &attr);
- DCHECK(!error) << "pthread_mutex_init: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutex_init", error);
error = pthread_mutexattr_destroy(&attr);
- DCHECK(!error) << "pthread_mutexattr_destroy: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutexattr_destroy", error);
}
Mutex::~Mutex() {
int error = pthread_mutex_destroy(&impl_);
- DCHECK(!error) << "pthread_mutex_destroy: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutex_destroy", error);
}
void Mutex::Lock() MOJO_EXCLUSIVE_LOCK_FUNCTION() {
int error = pthread_mutex_lock(&impl_);
- DCHECK(!error) << "pthread_mutex_lock: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutex_lock", error);
}
void Mutex::Unlock() MOJO_UNLOCK_FUNCTION() {
int error = pthread_mutex_unlock(&impl_);
- DCHECK(!error) << "pthread_mutex_unlock: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error, "pthread_mutex_unlock", error);
}
bool Mutex::TryLock() MOJO_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
int error = pthread_mutex_trylock(&impl_);
- DCHECK(!error || error == EBUSY) << "pthread_mutex_trylock: "
- << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(!error || error == EBUSY, "pthread_mutex_trylock",
+ error);
return !error;
}
void Mutex::AssertHeld() MOJO_ASSERT_EXCLUSIVE_LOCK() {
int error = pthread_mutex_lock(&impl_);
- DCHECK_EQ(error, EDEADLK) << ". pthread_mutex_lock: " << strerror(error);
+ INTERNAL_DCHECK_WITH_ERRNO(error == EDEADLK, "pthread_mutex_lock", error);
}
-} // namespace system
+} // namespace util
} // namespace mojo
#endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
« no previous file with comments | « mojo/edk/util/mutex.h ('k') | mojo/edk/util/mutex_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698