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

Unified Diff: mojo/edk/base_edk/thread_utils.cc

Issue 1639093002: Add //mojo/edk/platform/thread_utils.* containing "yield" and "sleep". (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 | « mojo/edk/base_edk/BUILD.gn ('k') | mojo/edk/platform/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/base_edk/thread_utils.cc
diff --git a/mojo/edk/base_edk/thread_utils.cc b/mojo/edk/base_edk/thread_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..611bffc13b2207264fb7f73442290364048001d0
--- /dev/null
+++ b/mojo/edk/base_edk/thread_utils.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 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.
+
+// This file implements the functions declared in
+// //mojo/edk/platform/thread_utils.h.
+
+#include "mojo/edk/platform/thread_utils.h"
+
+#include <stdint.h>
+
+#include <limits>
+
+#include "base/logging.h"
+#include "base/threading/platform_thread.h"
+#include "base/time/time.h"
+
+namespace mojo {
+namespace platform {
+
+void ThreadYield() {
+ base::PlatformThread::YieldCurrentThread();
+}
+
+void ThreadSleep(MojoDeadline duration) {
+ // Note: This also effectively checks that |duration| isn't
+ // |MOJO_DEADLINE_INDEFINITE|.
+ DCHECK_LE(duration,
+ static_cast<MojoDeadline>(std::numeric_limits<int64_t>::max()));
+
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMicroseconds(static_cast<int64_t>(duration)));
+}
+
+} // namespace platform
+} // namespace mojo
« no previous file with comments | « mojo/edk/base_edk/BUILD.gn ('k') | mojo/edk/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698