]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unsupported/thread.rs
Rollup merge of #105482 - wesleywiser:fix_debuginfo_ub, r=tmiasko
[rust.git] / library / std / src / sys / unsupported / thread.rs
1 use super::unsupported;
2 use crate::ffi::CStr;
3 use crate::io;
4 use crate::num::NonZeroUsize;
5 use crate::time::Duration;
6
7 pub struct Thread(!);
8
9 pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
10
11 impl Thread {
12     // unsafe: see thread::Builder::spawn_unchecked for safety requirements
13     pub unsafe fn new(_stack: usize, _p: Box<dyn FnOnce()>) -> io::Result<Thread> {
14         unsupported()
15     }
16
17     pub fn yield_now() {
18         // do nothing
19     }
20
21     pub fn set_name(_name: &CStr) {
22         // nope
23     }
24
25     pub fn sleep(_dur: Duration) {
26         panic!("can't sleep");
27     }
28
29     pub fn join(self) {
30         self.0
31     }
32 }
33
34 pub fn available_parallelism() -> io::Result<NonZeroUsize> {
35     unsupported()
36 }
37
38 pub mod guard {
39     pub type Guard = !;
40     pub unsafe fn current() -> Option<Guard> {
41         None
42     }
43     pub unsafe fn init() -> Option<Guard> {
44         None
45     }
46 }