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 7, 2024
1 parent fe148f2 commit d4e8724
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions 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(),
});

#[cfg(feature = "panic_on_webworker")]
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]));
#[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");
});
#[cfg(feature = "panic_on_webworker")]
CHECK_THREAD.with(|val| val.call_once(|| {
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 d4e8724

Please sign in to comment.