possible to remove start_detached allocation
kirkshoop opened this issue · comments
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.
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
.)
Delegating to the caller means that the result can stored in a global optional var.
this guarantees the lifetime and removes the allocation.
I built start_now() as a replacement for start_detached() This shows how the return value can be used to remove the allocation..