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 |