Skip to content

Clarify that scheduler returned by get_scheduler on receiver is only valid until the operation completes #112

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

Open
ericniebler opened this issue Dec 8, 2023 · 2 comments
Labels
bug Something isn't working design needs-proposed-resolution This issue does not yet have a proposed resolution but needs one P1

Comments

@ericniebler
Copy link
Collaborator

ericniebler commented Dec 8, 2023

Issue by lewissbaker
Thursday Dec 02, 2021 at 21:11 GMT
Originally opened as NVIDIA/stdexec#295


Similar to the wording in the get_stop_token() CPO, which only guarantees that the token returned is valid until the operation completes, we should do the same for the get_scheduler() CPO.

We should be careful to clarify what operations are valid after calling set_xxx on the receiver.
e.g. is it valid to call:

  • the destructor of the scheduler after set_xxx (could some schedulers be reference-counting in the destructor?)
  • the move constructor?
  • the schedule() CPO (but just not connect/start it)

Another possibility is to tie the end-of-validity of the scheduler to the destructor of the receiver (or move-constructed copy of the receiver).

Proposed resolution:

Change [exec.recv.concepts] p3 as follows:

 3. Let rcvr be a receiver and let op_state be an operation state associated with an
    asynchronous operation created by connecting rcvr with a sender. 
-   Let token be a stop token equal to get_stop_token(get_env(rcvr)). token shall
-   remain valid for the duration of the
+   Let o be an object equal to Q(get_env(rcvr)) where Q is one of:
+     * get_allocator
+     * get_stop_token
+     * get_scheduler
+     * get_delegation_scheduler.
+   o shall remain valid for the duration of the
    asynchronous operation's lifetime ([exec.async.ops]).

    [Note 1: This means that, unless it knows about further guarantees provided by the
-   type of rcvr, the implementation of op_state cannot use token after it executes a
+   type of rcvr, the implementation of op_state cannot use o after it executes a
    completion operation. This also implies that any stop callbacks registered on
-   token
+   rcvr's stop token
    must be destroyed before the invocation of the completion operation. — end note]
@ericniebler ericniebler added bug Something isn't working standardization labels Dec 8, 2023
@ericniebler
Copy link
Collaborator Author

Comment by LeeHowes
Friday Dec 03, 2021 at 00:19 GMT


We might want to use the more general wording if get_scheduler is a broader query than just on the receiver.

@lewissbaker lewissbaker added P1 design discussion We need to talk about this; there's nothing actionable here yet labels Jul 11, 2024
@ericniebler ericniebler added needs-proposed-resolution This issue does not yet have a proposed resolution but needs one and removed discussion We need to talk about this; there's nothing actionable here yet labels Feb 7, 2025
@ericniebler
Copy link
Collaborator Author

@lewissbaker are you happy with the wording of my proposed resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working design needs-proposed-resolution This issue does not yet have a proposed resolution but needs one P1
Projects
None yet
Development

No branches or pull requests

2 participants