embassy
embassy copied to clipboard
SyncExecutor::poll / set_alarm_callback
Can you help me to understand why that set_alarm_callback need to call in every poll? May be I'm wrong but I think all args of set_alarm_callback are fixed value.
- alarm is allocated when SyncExecutor was created
- alarm_callback is a fixed callback routine
- ctx is always the 'untyped' pointer of the SyncExecutor instance.
I cannot find any method in SyncExecutor implementation for manipulation of those values (alarm and alarm_callback).
It seems that this call is redundant and wastes time.
It would be helpful if you give me some hints why this is necessary.
It can't be done earlier in new because the user might move the executor, which will invalidate the ctx pointer. Only by the time poll is called we know the executor won't move anymore, thanks to taking &'static self.
Clear. Thank you for your quick response. I'm using embassy on 'single core' chip. So in my customised version I can/will put it into 'new'.
You can't put it into new, the executor moves when you return it, and the user might move it further. It has nothing to do with single/multi-core.
I went through the #[main] attribute macro. You are right (of course). Thanks for taking the time to help novices.
I'm considering this resolved, reopen if not