-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
event_periodic_callback: add getter for user context, one-shot event #18656
event_periodic_callback: add getter for user context, one-shot event #18656
Conversation
static inline void *event_periodic_callback_get_arg(event_periodic_callback_t *event) | ||
{ | ||
return event->event.arg; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me,
- arg = ev->event.arg;
+ arg = event_periodic_callback_get_arg(ev);
does not feel too much of a win. But it may provide some flexibility for future refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I wanted to not expose the internal event struct to the user, they should only deal with event_periodic_callback_t
Contribution description
event_periodic_callback_get_arg()
This is a purely aesthetic addition: When initializing an event, e.g. to measure a sensor, I want to have a locally visible
static lm75_t lm75_dev
that I use as the event argument.I can access this in the callback, but if I want to access it outside the callback, e.g. to re-init the sensor after the callback was suspended, I have to access
event->event.arg
which feels dirty.Instead, add a nice getter function that does the same.
event_callback_oneshot()
An easy helper to execute a function by the event thread, to be called e.g. in an interrupt or by another function that is not supposed to block.
Testing procedure
Issues/PRs references