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

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.cc

Issue 1380043002: Implement a simple ThreadChecker for Mojo and add to |internal::SharedData| and |internal::Router|. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build rules. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.cc
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.cc b/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8a16e24655952f8c786cf2b1337a422e178cb2b
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.cc
@@ -0,0 +1,24 @@
+// 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.
+
+#include "mojo/public/cpp/bindings/lib/thread_checker_posix.h"
+
+#include <assert.h>
+
+namespace mojo {
+namespace internal {
+
+ThreadCheckerPosix::ThreadCheckerPosix() : attached_thread_id_(pthread_self()) {
+}
+
+ThreadCheckerPosix::~ThreadCheckerPosix() {
+ assert(CalledOnValidThread());
+}
+
+bool ThreadCheckerPosix::CalledOnValidThread() const {
+ return pthread_equal(pthread_self(), attached_thread_id_);
+}
+
+} // namespace internal
+} // namespace mojo
« no previous file with comments | « third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698