Skip to content

Commit a3f9239

Browse files
DdystopiaAfoHT
authored andcommitted
feat(executor): add standalone waker constructor
1 parent fa0d9be commit a3f9239

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rtic/src/export/executor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,16 @@ impl<F: Future + 'static> AsyncTaskExecutor<F> {
192192
self.set_pending();
193193
}
194194

195+
#[inline(always)]
196+
pub const fn waker(&self, wake: fn()) -> Waker {
197+
unsafe { Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE)) }
198+
}
199+
195200
/// Poll the future in the executor.
196201
#[inline(always)]
197202
pub fn poll(&self, wake: fn()) {
198203
if self.is_running() && self.check_and_clear_pending() {
199-
let waker = unsafe { Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE)) };
204+
let waker = self.waker(wake);
200205
let mut cx = Context::from_waker(&waker);
201206
let future = unsafe { Pin::new_unchecked(&mut *(self.task.get() as *mut F)) };
202207

0 commit comments

Comments
 (0)