diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-05-14 18:21:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-14 18:21:53 +0200 |
| commit | d732aeff914b9c3bf53ba1857ead33745c00c88a (patch) | |
| tree | b06ef9a8a3da8bbf23520dd32a55b47a9fbb8fad | |
| parent | 746b8ca083395fbad72d2eb110157ae316e0d480 (diff) | |
| parent | 2d39f5abcd3953eb1578f718c75c39c457bcb009 (diff) | |
| download | rust-d732aeff914b9c3bf53ba1857ead33745c00c88a.tar.gz rust-d732aeff914b9c3bf53ba1857ead33745c00c88a.zip | |
Rollup merge of #72141 - kornelski:dontsleep, r=joshtriplett
Warn against thread::sleep in async fn I've seen `thread::sleep` wrecking havoc in async servers. There's already an [issue for clippy](https://github.com/rust-lang/rust-clippy/issues/4377), but the std docs could warn against it too.
| -rw-r--r-- | src/libstd/thread/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 738f07250b5..3134a596756 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -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 @@ -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 |
