Skip to content

Wait strategies per event handler.#43

Open
MathisWellmann wants to merge 3 commits into
nicholassm:mainfrom
MathisWellmann:wait-strategies
Open

Wait strategies per event handler.#43
MathisWellmann wants to merge 3 commits into
nicholassm:mainfrom
MathisWellmann:wait-strategies

Conversation

@MathisWellmann

Copy link
Copy Markdown

Hi,
I'm using disruptor to 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 dedicated WaitStrategy per 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:
2026-07-13-173425_hyprshot
Essentially passing in the wait_strategy for 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 Processor trait that contains the relevant information about how to run each threads instead of having:

  • handle_events_with
  • handle_events_and_state_with
  • handle_events_with_wait_strategy
  • handle_events_and_state_with_wait_strategy
    Then 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.nix is just providing a reproducible dev shell so I can work with this crate on NixOS.

@nicholassm

Copy link
Copy Markdown
Owner

Hi Mathis,

Thanks for the PR!
I'll read/review and revert.

Kind regards
Nicholas

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.

2 participants