From a3f9239fba2e99a9389980a0736547ff65ae4bc7 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Thu, 16 Jan 2025 14:28:56 +0100 Subject: feat(executor): add standalone waker constructor --- rtic/src/export/executor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rtic/src/export/executor.rs b/rtic/src/export/executor.rs index bc31bf8..7bc7582 100644 --- a/rtic/src/export/executor.rs +++ b/rtic/src/export/executor.rs @@ -192,11 +192,16 @@ impl AsyncTaskExecutor { self.set_pending(); } + #[inline(always)] + pub const fn waker(&self, wake: fn()) -> Waker { + unsafe { Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE)) } + } + /// Poll the future in the executor. #[inline(always)] pub fn poll(&self, wake: fn()) { if self.is_running() && self.check_and_clear_pending() { - let waker = unsafe { Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE)) }; + let waker = self.waker(wake); let mut cx = Context::from_waker(&waker); let future = unsafe { Pin::new_unchecked(&mut *(self.task.get() as *mut F)) }; -- cgit v1.2.3