aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Babak <alexanderbabak@proton.me>2025-01-16 14:28:56 +0100
committerHenrik Tjäder <henrik@tjaders.com>2025-06-15 11:02:15 +0000
commita3f9239fba2e99a9389980a0736547ff65ae4bc7 (patch)
tree9a511fb7717f0d105f4bcd0d4a8f62c5f7f0579d
parentfa0d9be6f1931ec8dc3c9e6c71bab4690e4a9277 (diff)
feat(executor): add standalone waker constructor
-rw-r--r--rtic/src/export/executor.rs7
1 files changed, 6 insertions, 1 deletions
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<F: Future + 'static> AsyncTaskExecutor<F> {
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)) };