libunifex
libunifex copied to clipboard
Enforcing blocking_kind for stop_when source sender
Should the blocking_kind
of the source
of stop_when
to be enforced as never
? Since if the source sender is blocking, the trigger
operation would never start until the source
operation finishes, which defeat the purpose of the algorithm.
There are some tradeoffs with its behaviour here with launching the source first or the trigger first.
One thing I've been thinking about is actually having it launch the trigger first. If the trigger was, say, a schedule_after() operation because you are trying to implement a timeout then the timer won't actually be started until after the source's start() method returns, potentially resulting in a longer timeout. Starting the trigger first would allow setting up the timer first and allow it to cancel the source more promptly.
If the source completes synchronously the need to be able to cancel the long-running operation is less. A synchronously-completing operation may not even support cancellation. So launching the source operation first would mean that the trigger could avoid the overhead of setting up a timer if the source completed synchronously and had already requested cancellation of the trigger.