Skip to content

Add execution::invoke() algorithm #303

Open
@lewissbaker

Description

@lewissbaker

It seems reasonably common to want to invoke a function with some arguments on some execution context as an asynchronous operation, representing this operation as a sender.

Several examples currently build this sort of operation out of a combination of just() and then(), possibly combined with starts_on() to do the scheduling.

The pattern of writing then(just(), [] { do_something(); }) just to wrap up a call to some lambda in a sender seems like an overly complicated (and also compile-time-expensive) way of writing this.

It would be more concise and also should be much simpler in terms of implementation (e.g. computing completion-signatures) to just have an algorithm that takes an invocable and that returns a sender that completes with the result of invoking that function/lambda when the sender is started.

e.g. execution::invoke([] { do_something(); }) instead of the just+then expression above.

This could then be composed with starts_on() to execute do_something on a particular scheduler's context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1enhancementNew feature or requestgood-first-issueSomething to try if you're new to the projectneeds-paperNeeds a paper to be written

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions