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

Prototype for context shared between timers #11

Draft
wants to merge 1 commit into
base: refactor/cleanup
Choose a base branch
from

Conversation

AssemblyJohn
Copy link

@AssemblyJohn AssemblyJohn commented Oct 21, 2024

In this PR a small modification has been made, to allow multiple timers to run from the same asio::io_context, from a unique thread instead of spawning a different thread for each timer.

  1. The code will keep backwards compatibility, no application re-design would be required on basic usage.
  2. On a custom timer that uses a boost::asio::io_context* io_context constructor an extra work guard should be placed around the provided io_context from exterior code, the custom ctor will not take care of that

@AssemblyJohn
Copy link
Author

This is a draft PR that does not solve some issues that are open to discussion:

  1. Using a static singleton shared between all timer instances, in case the 'SharedContext' template param is set to true. Alternatives to the singleton pattern to be considered
  2. Code wait issues. If user code uses thread::sleep or conditional variables or other blocking functions from a timer callback major disruptions in callback invocation can occur. It presumes that any work done in timer callbacks is quickly done and the function returns

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

Successfully merging this pull request may close these issues.

1 participant