OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file implements the functions declared in |
| 6 // //mojo/edk/platform/thread_utils.h. |
| 7 |
| 8 #include "mojo/edk/platform/thread_utils.h" |
| 9 |
| 10 #include <stdint.h> |
| 11 |
| 12 #include <limits> |
| 13 |
| 14 #include "base/logging.h" |
| 15 #include "base/threading/platform_thread.h" |
| 16 #include "base/time/time.h" |
| 17 |
| 18 namespace mojo { |
| 19 namespace platform { |
| 20 |
| 21 void ThreadYield() { |
| 22 base::PlatformThread::YieldCurrentThread(); |
| 23 } |
| 24 |
| 25 void ThreadSleep(MojoDeadline duration) { |
| 26 // Note: This also effectively checks that |duration| isn't |
| 27 // |MOJO_DEADLINE_INDEFINITE|. |
| 28 DCHECK_LE(duration, |
| 29 static_cast<MojoDeadline>(std::numeric_limits<int64_t>::max())); |
| 30 |
| 31 base::PlatformThread::Sleep( |
| 32 base::TimeDelta::FromMicroseconds(static_cast<int64_t>(duration))); |
| 33 } |
| 34 |
| 35 } // namespace platform |
| 36 } // namespace mojo |
OLD | NEW |