Skip to content

Commit

Permalink
Rollup merge of rust-lang#72141 - kornelski:dontsleep, r=joshtriplett
Browse files Browse the repository at this point in the history
Warn against thread::sleep in async fn

I've seen `thread::sleep` wrecking havoc in async servers. There's already an [issue for clippy](rust-lang/rust-clippy#4377), but the std docs could warn against it too.
  • Loading branch information
Dylan-DPC committed May 14, 2020
2 parents 746b8ca + 2d39f5a commit d732aef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/thread/mod.rs
Expand Up @@ -737,6 +737,8 @@ pub fn panicking() -> bool {
/// The thread may sleep longer than the duration specified due to scheduling
/// specifics or platform-dependent functionality. It will never sleep less.
///
/// This function is blocking, and should not be used in `async` functions.
///
/// # Platform-specific behavior
///
/// On Unix platforms, the underlying syscall may be interrupted by a
Expand All @@ -763,6 +765,8 @@ pub fn sleep_ms(ms: u32) {
/// The thread may sleep longer than the duration specified due to scheduling
/// specifics or platform-dependent functionality. It will never sleep less.
///
/// This function is blocking, and should not be used in `async` functions.
///
/// # Platform-specific behavior
///
/// On Unix platforms, the underlying syscall may be interrupted by a
Expand Down

0 comments on commit d732aef

Please sign in to comment.