diff options
| author | joboet <jonasboettiger@icloud.com> | 2022-10-06 22:46:47 +0200 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2022-10-06 22:46:47 +0200 |
| commit | 0ad4dd494a67a0fffc5a3e4df08f0c26cf074c59 (patch) | |
| tree | 4c7659320431b76d12fa2157b0a2451c71e21381 /library/std/src/thread | |
| parent | 99182dd8058f0a1153b8b7fcf873028caa6fbfa7 (diff) | |
| download | rust-0ad4dd494a67a0fffc5a3e4df08f0c26cf074c59.tar.gz rust-0ad4dd494a67a0fffc5a3e4df08f0c26cf074c59.zip | |
std: add thread parking tests
Diffstat (limited to 'library/std/src/thread')
| -rw-r--r-- | library/std/src/thread/tests.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 130e47c8d44..dfb8765ab4e 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -245,6 +245,28 @@ fn test_try_panic_any_message_unit_struct() { } #[test] +fn test_park_unpark_before() { + for _ in 0..10 { + thread::current().unpark(); + thread::park(); + } +} + +#[test] +fn test_park_unpark_called_other_thread() { + for _ in 0..10 { + let th = thread::current(); + + let _guard = thread::spawn(move || { + super::sleep(Duration::from_millis(50)); + th.unpark(); + }); + + thread::park(); + } +} + +#[test] fn test_park_timeout_unpark_before() { for _ in 0..10 { thread::current().unpark(); |
