Wait strategies per event handler.#43
Open
MathisWellmann wants to merge 3 commits into
Open
Conversation
Owner
|
Hi Mathis, Thanks for the PR! Kind regards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I'm using
disruptorto fan-out to N worker threads that each process different features that have varying compute demands and it would be convenient to be able to set a dedicatedWaitStrategyper worker.E.g when some threads have very little to compute they can choose a longer sleep strategy instead of busy spinning and burning CPU.
The primary change is is the following:

Essentially passing in the
wait_strategyfor every processor instead of using the shared builder one.What do you think of this feature?
To be fair, I think all of these extra methods on the builders get annoying pretty quickly so it might be worth thinking about creating something like a
Processortrait that contains the relevant information about how to run each threads instead of having:handle_events_withhandle_events_and_state_withhandle_events_with_wait_strategyhandle_events_and_state_with_wait_strategyThen we could have a single method in the builder that takes some
impl Processor, but I guess this would be for another PR and a redesign of the API, which I've not fully fleshed out.Btw. the
flake.nixis just providing a reproducible dev shell so I can work with this crate on NixOS.