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

Unified Diff: mojo/edk/system/test/sleep.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/system/test/sleep.h ('k') | mojo/edk/system/test/sleep_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/test/sleep.cc
diff --git a/mojo/edk/system/test/sleep.cc b/mojo/edk/system/test/sleep.cc
deleted file mode 100644
index 45f0587c6393bc42abb88aa7ecc0022c3da6a823..0000000000000000000000000000000000000000
--- a/mojo/edk/system/test/sleep.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2013 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/edk/system/test/sleep.h"
-
-#include <errno.h>
-#include <stdint.h>
-#include <time.h>
-
-#include <limits>
-
-#include "base/logging.h"
-#include "mojo/edk/system/test/timeouts.h"
-
-namespace mojo {
-namespace system {
-namespace test {
-
-void Sleep(MojoDeadline duration) {
- // TODO(vtl): This doesn't handle |MOJO_DEADLINE_INDEFINITE|. Should it?
- DCHECK_NE(duration, MOJO_DEADLINE_INDEFINITE);
-
- const uint64_t kMicrosecondsPerSecond = 1000000ULL;
- const uint64_t kNanosecondsPerMicrosecond = 1000ULL;
-
- uint64_t sleep_time_seconds = duration / kMicrosecondsPerSecond;
- // |sleep_time.tv_sec| is a |time_t|.
- DCHECK_LE(sleep_time_seconds,
- static_cast<uint64_t>(std::numeric_limits<time_t>::max()));
- uint64_t sleep_time_nanoseconds =
- (duration % kMicrosecondsPerSecond) * kNanosecondsPerMicrosecond;
-
- struct timespec sleep_time;
- sleep_time.tv_sec = static_cast<time_t>(sleep_time_seconds);
- sleep_time.tv_nsec = static_cast<long>(sleep_time_nanoseconds);
-
- struct timespec sleep_time_remaining;
- while (nanosleep(&sleep_time, &sleep_time_remaining) == -1) {
- PCHECK(errno == EINTR) << "nanosleep";
- sleep_time = sleep_time_remaining;
- }
-}
-
-void SleepMilliseconds(unsigned duration_milliseconds) {
- Sleep(DeadlineFromMilliseconds(duration_milliseconds));
-}
-
-} // namespace test
-} // namespace system
-} // namespace mojo
« no previous file with comments | « mojo/edk/system/test/sleep.h ('k') | mojo/edk/system/test/sleep_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698