about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristiaan Dirkx <christiaan@dirkx.email>2021-04-28 15:51:14 +0200
committerChristiaan Dirkx <christiaan@dirkx.email>2021-04-28 15:51:14 +0200
commit52fa9daa645772603dc170a3f3bed5cab73d646d (patch)
tree68c6619cbae3b50e7837424ec6ff34c8783f9f89
parent76a04dd3f8b2500d9e524dca122814fd5a3e25e4 (diff)
downloadrust-52fa9daa645772603dc170a3f3bed5cab73d646d.tar.gz
rust-52fa9daa645772603dc170a3f3bed5cab73d646d.zip
Rework `wasm::thread` to `thread_atomics`
-rw-r--r--library/std/src/sys/wasm/mod.rs5
-rw-r--r--library/std/src/sys/wasm/thread_atomics.rs (renamed from library/std/src/sys/wasm/thread.rs)22
2 files changed, 8 insertions, 19 deletions
diff --git a/library/std/src/sys/wasm/mod.rs b/library/std/src/sys/wasm/mod.rs
index 8705910c73a..71877fce993 100644
--- a/library/std/src/sys/wasm/mod.rs
+++ b/library/std/src/sys/wasm/mod.rs
@@ -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;
     }
 }
 
diff --git a/library/std/src/sys/wasm/thread.rs b/library/std/src/sys/wasm/thread_atomics.rs
index b7bf95c89b4..54bc877aa7d 100644
--- a/library/std/src/sys/wasm/thread.rs
+++ b/library/std/src/sys/wasm/thread_atomics.rs
@@ -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};