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

Add a mechanism to wake-up an external eventloop when a timer is inserted #6

Open
Matthias247 opened this issue Sep 10, 2019 · 0 comments

Comments

@Matthias247
Copy link
Owner

Matthias247 commented Sep 10, 2019

The next_expiration API for the GenericTimerService doesn't work well in a multithreaded context. If an eventloop works like:

loop {
    let expiration = timer.next_expiration();
    let events = wait_for_events(expiration);
    handle_events(events);
}

it might miss the expiry of a timer if that one gets registered while the loop is already blocked in wait_for_events with a longer timeout.

Therefore the only reliable way to drive a timer in a multithreaded context is currently to poll the timer in regular intervals independent of the number of registered timers.

To fix this issue GenericTimerService could provide a hook that allows to wakeup the eventloop if a new timer gets registered whose expiry data is earlier than the previously registered timer.

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

No branches or pull requests

1 participant