Skip to content

Commit 888418a

Browse files
committed
Use Unsupported on platforms where available_concurrency is not implemented.
1 parent 05ec710 commit 888418a

File tree

6 files changed

+9
-21
lines changed

6 files changed

+9
-21
lines changed

library/std/src/sys/hermit/thread.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(dead_code)]
22

3+
use super::unsupported;
34
use crate::ffi::CStr;
45
use crate::io;
56
use crate::mem;
@@ -97,10 +98,7 @@ impl Thread {
9798
}
9899

99100
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
100-
Err(io::Error::new_const(
101-
io::ErrorKind::NotFound,
102-
&"The number of hardware threads is not known for the target platform",
103-
))
101+
unsupported()
104102
}
105103

106104
pub mod guard {

library/std/src/sys/sgx/thread.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg_attr(test, allow(dead_code))] // why is this necessary?
2+
use super::unsupported;
23
use crate::ffi::CStr;
34
use crate::io;
45
use crate::num::NonZeroUsize;
@@ -137,10 +138,7 @@ impl Thread {
137138
}
138139

139140
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
140-
Err(io::Error::new_const(
141-
io::ErrorKind::NotFound,
142-
&"The number of hardware threads is not known for the target platform",
143-
))
141+
unsupported()
144142
}
145143

146144
pub mod guard {

library/std/src/sys/unix/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
276276
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
277277
} else {
278278
// FIXME: implement on vxWorks, Redox, Haiku, l4re
279-
Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform"))
279+
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
280280
}
281281
}
282282
}

library/std/src/sys/unsupported/thread.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ impl Thread {
3232
}
3333

3434
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
35-
Err(io::Error::new_const(
36-
io::ErrorKind::NotFound,
37-
&"The number of hardware threads is not known for the target platform",
38-
))
35+
unsupported()
3936
}
4037

4138
pub mod guard {

library/std/src/sys/wasi/thread.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ impl Thread {
6565
}
6666

6767
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
68-
Err(io::Error::new_const(
69-
io::ErrorKind::NotFound,
70-
&"The number of hardware threads is not known for the target platform",
71-
))
68+
unsupported()
7269
}
7370

7471
pub mod guard {

library/std/src/sys/wasm/atomics/thread.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::unsupported;
12
use crate::ffi::CStr;
23
use crate::io;
34
use crate::num::NonZeroUsize;
@@ -41,10 +42,7 @@ impl Thread {
4142
}
4243

4344
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
44-
Err(io::Error::new_const(
45-
io::ErrorKind::NotFound,
46-
&"The number of hardware threads is not known for the target platform",
47-
))
45+
unsupported()
4846
}
4947

5048
pub mod guard {

0 commit comments

Comments
 (0)