scala/scala-async

Fail Fast Mode

retronym opened this issue · 1 comments

Could scala-async handle some of use cases describe in https://github.com/jedesah/computation-expressions?

I think it would be a relatively small modification to our macro to offer a fail-fast mode. The user would need to opt in to this, perhaps by importing a different async macro.

In this flavour of the async, we'd immediately register the state machine as an onFailure callback on each future that is started. The first throwable received would be used to fail the result promise of the async block. Some care would be needed to avoid races, e.g. by making the existing and new code that fulfils that Promise obtain a lock when doing so.

As of async 1.0 / Scala 2.12.12, this could be built quite simply as as third party async implementation based on the core transform that is now part of scalac -Xasync. Out of scope for scala-async itself.