Skip to content

Ownership of values sent through the value channel #72

Open
@ericniebler

Description

@ericniebler

Issue by ericniebler
Wednesday Aug 03, 2022 at 22:56 GMT
Originally opened as NVIDIA/stdexec#565


@lewissbaker has bemoaned the fact that a receiver doesn't know whether a particular argument is a reference to data in the operation state. If so, completing the nested receiver will invalidate the values because it (typically) results in the destruction of the operation state. As a consequence, receivers sometimes have to defensively copy the values into locals before signalling completion downstream.

I've been thinking we can use the completion signatures to convey this information. We can let set_value_t(Widget) denote arguments whose lifetimes do not depend on the operation state, and let set_value_t(Widget&&), set_value_t(Widget&), set_value_t(const Widget&) denote references to data stored in the operation state.

This idea is incomplete. I can imagine a sender that has both set_value_t(Widget) and set_value_t(const Widget&) as completion signatures. An invocation of a receiver's set_value will have a hard time inferring its corresponding completion signature.

Not to mention the fact that this is fiddly and easy to get wrong.

Food for thought.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2discussionWe need to talk about this; there's nothing actionable here yetenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions