Refuse a wasm threads build where the Send and Sync impls assume one thread

This commit is contained in:
Dennis Kobert
2026-09-08 13:15:18 +00:00
parent 2b5845464c
commit 148008c695
2 changed files with 9 additions and 0 deletions

View File

@@ -217,6 +217,9 @@ unsafe impl Send for SourceHandle {}
#[cfg(target_family = "wasm")]
unsafe impl Sync for SourceHandle {}
#[cfg(all(target_family = "wasm", target_feature = "atomics"))]
compile_error!("SourceHandle's wasm Send/Sync rest on a single-threaded build; a +atomics target needs the stored node bounded instead");
impl SourceHandle {
pub fn new_record<T: 'static>(node: std::sync::Arc<ErasedRecordNode>) -> Self {
Self::new_erased(node, record_source_type::<T>())

View File

@@ -30,6 +30,9 @@ unsafe impl Send for RuntimeHandle {}
#[cfg(target_family = "wasm")]
unsafe impl Sync for RuntimeHandle {}
#[cfg(all(target_family = "wasm", target_feature = "atomics"))]
compile_error!("RuntimeHandle's wasm Send/Sync rest on a single-threaded build; a +atomics target needs the payload bounded instead");
impl std::fmt::Debug for RuntimeHandle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RuntimeHandle").finish_non_exhaustive()
@@ -102,6 +105,9 @@ unsafe impl<S> Send for GraphRuntime<S> {}
#[cfg(target_family = "wasm")]
unsafe impl<S> Sync for GraphRuntime<S> {}
#[cfg(all(target_family = "wasm", target_feature = "atomics"))]
compile_error!("GraphRuntime's wasm Send/Sync are unbounded in S and rest on a single-threaded build; a +atomics target needs S bounded instead");
impl<S> GraphRuntime<S> {
pub fn new(spawner: S) -> Self {
Self {