Skip to content

Is there any way to combine select! and join! macros? #2288

@peku33

Description

@peku33

I belive this is common scenario, when user wants to use select! and join! macros together.
The easiest example is a circuit breaker (like a timeout) for long running concurrect task.

For example:

use futures::{select, join};

async fn foo() {
    select! {
        (r1, r2) = join!(long_running_task_1, long_running_task_2) => { return result },
        _ = circuit_breaker => { report error },
    }
}

For now this wouldn't work, as join! and select! macros both awaits internally.

I found a few workarounds for this, but they aren't convinient nor elegant.

  • create async block, call join internally
  • use join, join2, join3 - does not allow any number of futures
  • join_all - required all futures to be returning the same type (or even to be the same type)

Is there any way to combine those two together?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions