Skip to content

Feature request: Add biased support to join! and try_join! #7304

@jlizen

Description

@jlizen

Is your feature request related to a problem? Please describe.
I have two long-running futures that I need to drive locally in a task.

Specifically, the futures are a AWS Lambda function handler listener, and secondary event listener that does some extra cleanup operations after the main event processing is complete. Something along these lines.

Normally I would reach for join! or try_join! for this. However, I don't actually want to rotate which future I poll first. I want to always poll my primary server if it is ready to make progress, over the 'cleanup' event listener. Context here is that an AWS Lambda only receives one request a time per node.

Instead, I want to invoke join! or try_join! in a way that always polls sequentially based on the order of futures in the macro body.

Describe the solution you'd like
Tokio added biased support to select! some time back - #2181

It would be great to have the same API for join! or try_join!

Describe alternatives you've considered
You can accomplish the same thing using select! in a loop, and select! does support biased.

This gets very verbose though since you need to explicitly continue polling subsequent futures after one of them finishes. join! and try_join! are much friendlier APIs for this use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-macrosModule: macros in the main Tokio crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions