Skip to content

Commit 7824528

Browse files
committed
std: use id-based thread parking on SOLID
1 parent 247e44e commit 7824528

File tree

5 files changed

+40
-179
lines changed

5 files changed

+40
-179
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use super::abi;
2+
use super::error::expect_success_aborting;
3+
use super::time::with_tmos;
4+
use crate::time::Duration;
5+
6+
pub type ThreadId = abi::ID;
7+
8+
pub use super::task::current_task_id_aborting as current;
9+
10+
pub fn park(_hint: usize) {
11+
match unsafe { abi::slp_tsk() } {
12+
abi::E_OK | abi::E_RLWAI => {}
13+
err => {
14+
expect_success_aborting(err, &"slp_tsk");
15+
}
16+
}
17+
}
18+
19+
pub fn park_timeout(dur: Duration, _hint: usize) {
20+
match with_tmos(dur, |tmo| unsafe { abi::tslp_tsk(tmo) }) {
21+
abi::E_OK | abi::E_RLWAI | abi::E_TMOUT => {}
22+
err => {
23+
expect_success_aborting(err, &"tslp_tsk");
24+
}
25+
}
26+
}
27+
28+
pub fn unpark(id: ThreadId, _hint: usize) {
29+
match unsafe { abi::wup_tsk(id) } {
30+
// It is allowed to try to wake up a destroyed or unrelated task, so we ignore all
31+
// errors that could result from that situation.
32+
abi::E_OK | abi::E_NOEXS | abi::E_OBJ | abi::E_QOVR => {}
33+
err => {
34+
expect_success_aborting(err, &"wup_tsk");
35+
}
36+
}
37+
}

library/std/src/sys/itron/wait_flag.rs

-72
This file was deleted.

library/std/src/sys/solid/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ mod itron {
1313
pub(super) mod spin;
1414
pub(super) mod task;
1515
pub mod thread;
16+
pub mod thread_parking;
1617
pub(super) mod time;
1718
use super::unsupported;
18-
pub mod wait_flag;
1919
}
2020

2121
pub mod alloc;
@@ -43,8 +43,8 @@ pub use self::itron::thread;
4343
pub mod memchr;
4444
pub mod thread_local_dtor;
4545
pub mod thread_local_key;
46+
pub use self::itron::thread_parking;
4647
pub mod time;
47-
pub use self::itron::wait_flag;
4848

4949
mod rwlock;
5050

library/std/src/sys_common/thread_parking/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ cfg_if::cfg_if! {
1414
} else if #[cfg(any(
1515
target_os = "netbsd",
1616
all(target_vendor = "fortanix", target_env = "sgx"),
17+
target_os = "solid_asp3",
1718
))] {
1819
mod id;
1920
pub use id::Parker;
20-
} else if #[cfg(target_os = "solid_asp3")] {
21-
mod wait_flag;
22-
pub use wait_flag::Parker;
2321
} else if #[cfg(any(windows, target_family = "unix"))] {
2422
pub use crate::sys::thread_parking::Parker;
2523
} else {

library/std/src/sys_common/thread_parking/wait_flag.rs

-102
This file was deleted.

0 commit comments

Comments
 (0)