aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-11-12 16:30:46 +0100
committerDario Nieuwenhuis <[email protected]>2024-11-12 16:30:46 +0100
commit853c5c567add8134b8419cf0a6a2b6c8cb0b0aa6 (patch)
tree58e8186c7c67a28787eadf18a80aa7dd411fbe38 /embassy-executor
parentbaeb59b5b8d63ef9bb6ecada518ea8b911d2dc30 (diff)
executor: compare vtable addr instead of contents.
Saves a whopping 44 bytes of text, yay.
Diffstat (limited to 'embassy-executor')
-rw-r--r--embassy-executor/src/raw/waker.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/embassy-executor/src/raw/waker.rs b/embassy-executor/src/raw/waker.rs
index d2256adfa..9c70f995a 100644
--- a/embassy-executor/src/raw/waker.rs
+++ b/embassy-executor/src/raw/waker.rs
@@ -43,7 +43,9 @@ pub fn task_from_waker(waker: &Waker) -> TaskRef {
43 // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 43 // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992
44 let hack: &WakerHack = unsafe { core::mem::transmute(waker) }; 44 let hack: &WakerHack = unsafe { core::mem::transmute(waker) };
45 45
46 if hack.vtable != &VTABLE { 46 // make sure to compare vtable addresses. Doing `==` on the references
47 // will compare the contents, which is slower.
48 if hack.vtable as *const _ != &VTABLE as *const _ {
47 panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") 49 panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.")
48 } 50 }
49 // safety: our wakers are always created with `TaskRef::as_ptr` 51 // safety: our wakers are always created with `TaskRef::as_ptr`