concurrency icon indicating copy to clipboard operation
concurrency copied to clipboard

why does syncWait.assumeOk throw when calling onDone?

Open WebFreak001 opened this issue 2 years ago • 3 comments

https://github.com/symmetryinvestments/concurrency/blob/7dd10addd320f908e62300bcef2702b9de9ac4a3/tests/ut/concurrency/sender.d#L21

I don't get why this test code passes - DoneSender should just make the task finish without value, while ThrowingSender makes it error/abort.

Why does the test check for assumeOk.shouldThrow throw like ThrowingSender?

WebFreak001 avatar Mar 08 '23 21:03 WebFreak001

Yeah, I am on the fence here.

With Senders there are 3 termination points: natural completion, completion due to cancellation and error. assumeOk only counts natural completion as correct, and errors out on the other 2.

DoneSender is a bit of a misnomer I guess, CancelSender would have been a bit better.

skoppe avatar Mar 09 '23 22:03 skoppe

onDone should probably also be called onCancel then I think?

WebFreak001 avatar Mar 10 '23 13:03 WebFreak001

onDone should probably also be called onCancel then I think?

Its actually called setDone. Emphasize on completion.

One thing about cancellation is that in terms of lifecycle its important to know when the cancellation is done. Its only when it is done that resources can be cleaned.

Senders signal completion, so the setValue, setDone, setError trifecta actually makes sense. And contrary to what I said yesterday, that makes DoneSender actually the more correct naming.

Sorry, the concurrency stuff has moved to the back of my mind a bit.

skoppe avatar Mar 10 '23 23:03 skoppe