Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize some Duration consuming methods #27655

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::io::prelude::*;
use std::net::TcpStream;
use std::path::{Path, PathBuf};
use std::process::{Command, Output, ExitStatus};
use std::time::Duration;

pub fn run(config: Config, testfile: &Path) {
match &*config.target {
Expand Down Expand Up @@ -431,7 +432,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
.expect(&format!("failed to exec `{:?}`", config.adb_path));
loop {
//waiting 1 second for gdbserver start
::std::thread::sleep_ms(1000);
::std::thread::sleep(Duration::new(1, 0));
if TcpStream::connect("127.0.0.1:5039").is_ok() {
break
}
Expand Down
6 changes: 4 additions & 2 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ pub fn catch_panic<F, R>(f: F) -> Result<R>
/// specifics or platform-dependent functionality. Note that on unix platforms
/// this function will not return early due to a signal being received or a
/// spurious wakeup.
#[deprecated(since = "1.4.0", reason = "use `thread::sleep` instead")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn sleep_ms(ms: u32) {
sleep(Duration::from_millis(ms as u64))
Expand All @@ -483,7 +484,7 @@ pub fn sleep_ms(ms: u32) {
/// signal being received or a spurious wakeup. Platforms which do not support
/// nanosecond precision for sleeping will have `dur` rounded up to the nearest
/// granularity of time they can sleep for.
#[unstable(feature = "thread_sleep", reason = "waiting on Duration")]
#[stable(feature = "thread_sleep", since = "1.4.0")]
pub fn sleep(dur: Duration) {
imp::Thread::sleep(dur)
}
Expand Down Expand Up @@ -533,6 +534,7 @@ pub fn park() {
/// amount of time waited to be precisely *ms* long.
///
/// See the module doc for more detail.
#[deprecated(since = "1.4.0", reason = "use `thread::park_timeout` instead")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn park_timeout_ms(ms: u32) {
park_timeout(Duration::from_millis(ms as u64))
Expand All @@ -553,7 +555,7 @@ pub fn park_timeout_ms(ms: u32) {
///
/// Platforms which do not support nanosecond precision for sleeping will have
/// `dur` rounded up to the nearest granularity of time they can sleep for.
#[unstable(feature = "park_timeout", reason = "waiting on Duration")]
#[stable(feature = "park_timeout", since = "1.4.0")]
pub fn park_timeout(dur: Duration) {
let thread = current();
let mut guard = thread.inner.lock.lock().unwrap();
Expand Down