Negations.
main
function setups that.Fun.protect
. It also keeps the difference between synchronous and asynchronous function call small, which in turn allows to sprinkle or retract asynchronous calls in your code more easily.Cooperative structured cancellation. More natural await
(previously join
) than the previous 2022 iteration of Affect
which only had structured cancellation topped with a franken-semi-cooperative cancellation. Notably:
await
ing. Fibers no longer return option
s.finally
handler on fiber calls. This was needed because if a fiber was cancelled before executing it would be denied any execution. This is no longer the case. This alone show in my opinion that the previous model was broken.The cooperative cancellation design was taken from the Swift concurrency model. So was aswell the notion of priority (they have one more level though). The whole result is not far from what Swift propose except: we don't have TaskGroup
s, it feels unecessary; we don't have detached tasks (this could easily be added); we don't have their "actors" which looks like their terminology for monitors.
One question that remains is if that model is not too costly for the OCaml runtime system for say mainly IO bound programs. Though given the flexibility of effects you could still elect to run for example one concurrency model per domain or simply on a single domain.
Except forcing an await in the scheduler that throws out the results in order to implement structured concurrency we don't do anything with fibers that are not awaited when a fiber returns. We could:
The first idea may make some pattern for speculative computing more involved that they could be: just cancel and forget, no need to await. The second idea it feels a bit odd to make a difference between values and exceptions, I think the stance should rather be either we disallow it or we don't care. We could have a scheduler tracing mode that reports them but if people start using as a design property (e.g. the forget mentioned) it would a noisy signal.