Rework wasm::thread
to thread_atomics
This commit is contained in:
parent
76a04dd3f8
commit
52fa9daa64
@ -37,7 +37,6 @@ pub mod pipe;
|
||||
pub mod process;
|
||||
#[path = "../unsupported/stdio.rs"]
|
||||
pub mod stdio;
|
||||
pub mod thread;
|
||||
#[path = "../unsupported/thread_local_dtor.rs"]
|
||||
pub mod thread_local_dtor;
|
||||
#[path = "../unsupported/thread_local_key.rs"]
|
||||
@ -57,6 +56,8 @@ cfg_if::cfg_if! {
|
||||
pub mod rwlock;
|
||||
#[path = "futex_atomics.rs"]
|
||||
pub mod futex;
|
||||
#[path = "thread_atomics.rs"]
|
||||
pub mod thread;
|
||||
} else {
|
||||
#[path = "../unsupported/condvar.rs"]
|
||||
pub mod condvar;
|
||||
@ -64,6 +65,8 @@ cfg_if::cfg_if! {
|
||||
pub mod mutex;
|
||||
#[path = "../unsupported/rwlock.rs"]
|
||||
pub mod rwlock;
|
||||
#[path = "../unsupported/thread.rs"]
|
||||
pub mod thread;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,20 +13,10 @@ impl Thread {
|
||||
unsupported()
|
||||
}
|
||||
|
||||
pub fn yield_now() {
|
||||
// do nothing
|
||||
}
|
||||
pub fn yield_now() {}
|
||||
|
||||
pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
pub fn set_name(_name: &CStr) {}
|
||||
|
||||
#[cfg(not(target_feature = "atomics"))]
|
||||
pub fn sleep(_dur: Duration) {
|
||||
panic!("can't sleep");
|
||||
}
|
||||
|
||||
#[cfg(target_feature = "atomics")]
|
||||
pub fn sleep(dur: Duration) {
|
||||
use crate::arch::wasm32;
|
||||
use crate::cmp;
|
||||
@ -46,9 +36,7 @@ impl Thread {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn join(self) {
|
||||
self.0
|
||||
}
|
||||
pub fn join(self) {}
|
||||
}
|
||||
|
||||
pub mod guard {
|
||||
@ -61,11 +49,9 @@ pub mod guard {
|
||||
}
|
||||
}
|
||||
|
||||
// This is only used by atomics primitives when the `atomics` feature is
|
||||
// enabled. In that mode we currently just use our own thread-local to store our
|
||||
// We currently just use our own thread-local to store our
|
||||
// current thread's ID, and then we lazily initialize it to something allocated
|
||||
// from a global counter.
|
||||
#[cfg(target_feature = "atomics")]
|
||||
pub fn my_id() -> u32 {
|
||||
use crate::sync::atomic::{AtomicU32, Ordering::SeqCst};
|
||||
|
Loading…
x
Reference in New Issue
Block a user