Skip to content
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

feature request: callback on timer functions to handle changes in the time list #871

Open
KammutierSpule opened this issue Mar 27, 2024 · 5 comments
Assignees

Comments

@KammutierSpule
Copy link

would be possible to register a callback on timer functions, so I can be notified when there is a change (insert/remove) on the list?

reason: this way I can wake-up a semaphore, so it will request the time to sleep until next timer... (instead of implement a "fixed polling rate").

@jwellbelove
Copy link
Contributor

Which particular timer type are you working with? I can send you a possible implementation for you to test.

@KammutierSpule
Copy link
Author

I don't mind to do a code review before testing, do you have it on a branch?

@jwellbelove
Copy link
Contributor

I've done a quick change to etl::callback_timer on feature/#871-callback-on-timer-functions-to-handle-changes-in-the-time-list

I added member functions:-

void set_event_callbacks(event_callback_type insert, event_callback_type remove)
void clear_event_callbacks()

Where event_callback_type is etl::delegate<void(etl::timer::id::type)>

I haven't written any unit tests for it yet.

@jwellbelove
Copy link
Contributor

If you want to set just one event callback then set the other to etl::callback_timer::event_callback{}

@KammutierSpule
Copy link
Author

I didn't tested but I had a look and seems ok, would be possible to merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants