Skip to content

Commit

Permalink
no-op workaround 5732 on non-wasm builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed Mar 7, 2023
1 parent ef2943c commit 2da57fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/workaround_5732.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ use std::sync::{Mutex, Once};

use bevy::prelude::*;

#[cfg(target_arch = "wasm32")]
static mut HANDLES: MaybeUninit<Mutex<HashSet<HandleUntyped>>> = MaybeUninit::uninit();
#[cfg(target_arch = "wasm32")]
static ONCE: Once = Once::new();

#[cfg(target_arch = "wasm32")]
pub(crate) fn store(handle: HandleUntyped) {
let handles = unsafe {
ONCE.call_once(|| {
Expand All @@ -20,3 +23,6 @@ pub(crate) fn store(handle: HandleUntyped) {
let mut guard = handles.lock().expect("expected to lock mutex");
guard.insert(handle);
}

#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn store(_handle: HandleUntyped) {}

0 comments on commit 2da57fa

Please sign in to comment.