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

Non-macro biased Select? #1145

Open
SimonSapin opened this issue Nov 7, 2024 · 0 comments
Open

Non-macro biased Select? #1145

SimonSapin opened this issue Nov 7, 2024 · 0 comments

Comments

@SimonSapin
Copy link
Contributor

#1040 added a select_biased! macro. Some internal functions gained an is_biased: bool parameter to support it, but the non-macro public API around the Select type does not expose this functionality at all. Some of those internal functions are only ever called with false. Biased functionality could be useful to add to the Select type but I’m not sure what the API should look like exactly. ~Doubling the number of methods does not feel great.

For context: I’m building a priority queue on top of an array of crossbeam channels. My receiver should block until any of the inner receivers are ready, but then consume one item from the highest-priority channel rather than arbitrary one. (Starvation is mitigated by "ageing" some low-priority items into a one-level-higher priority channel.) As a work-around I call Select::ready() then an explicit loop with Receiver::try_recv(), but this looks like it does redundant work compared to an hypothetical Select::biased_select()

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

No branches or pull requests

1 participant