Skip to content

Commit

Permalink
actually warn on web workers
Browse files Browse the repository at this point in the history
  • Loading branch information
9SMTM6 committed Sep 6, 2024
1 parent fe148f2 commit 53eeaa3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion embassy-time/src/driver_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ embassy_time_driver::time_driver_impl!(static DRIVER: TimeDriver = TimeDriver {
alarms: UninitCell::uninit(),
});

thread_local!{
static CHECK_THREAD: Once = Once::new();
}

impl TimeDriver {
fn ensure_init(&self) {
self.once.call_once(|| unsafe {
self.alarms.write(Mutex::new([ALARM_NEW; ALARM_COUNT]));
});
CHECK_THREAD.with(|val| val.call_once(|| {
log::info!("{}", is_web_worker_thread());
#[cfg(feature = "panic_on_webworker")]
assert!(!is_web_worker_thread(), "Timer currently has issues on Web Workers: https://github.com/embassy-rs/embassy/issues/3313");
});
}));
}
}

Expand Down

0 comments on commit 53eeaa3

Please sign in to comment.