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

Side by Side 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, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« 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