Skip to content
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

possible to remove start_detached allocation #77

Open
kirkshoop opened this issue May 10, 2024 · 3 comments
Open

possible to remove start_detached allocation #77

kirkshoop opened this issue May 10, 2024 · 3 comments

Comments

@kirkshoop
Copy link

change the object returned by start_detached from
optional<StopSource*>
to an immovable object that has request_stop()

the immovable object constructor will connect and start the sender.
request_stop will forward to the stop_src
If needed, a copyable stop_ref type can store a pointer to the immovable object and forward calls to its request_stop to the immoveable object.

@bdeane-intel
Copy link
Contributor

bdeane-intel commented May 13, 2024

I don't think returning the operation state would help - I think this would just move the allocation responsibility to the caller. The operation state needs to live somewhere that outlives the entire call stack (an interrupt). That's the job of the static_allocator at the moment.

(Admittedly, It might be that returning an optional<StopSource*> is of limited use too - we might want instead to access the stop source through the same type tag used for the call to start_detached.)

@kirkshoop
Copy link
Author

Delegating to the caller means that the result can stored in a global optional var.
this guarantees the lifetime and removes the allocation.

@kirkshoop
Copy link
Author

I built start_now() as a replacement for start_detached() This shows how the return value can be used to remove the allocation..

https://godbolt.org/z/Kx3a3Wq4s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants