by matthewwarren · 10y ago · 0 comments
¹ http://www.ps.uni-saarland.de/alice/manual/futures.html
² Well, it used "spawn" instead of "await". The semantics are very similar though.
That was the new idea that suddenly made those decades-old promises useful for the software industry, as it allowed both blocking-style code simplicity and callbacks-style IO scalability.
The ML link says “evaluates the expression exp in a new thread and returns immediately with a future of its result” which translates to “not scalable”.
Also, that's not a new idea. Blocking-style code with async I/O scaling was pioneered by Oz in 1991. (It did it a little bit differently from Alice ML.)
They are fundamentally different models, though.
F# uses a "cold task" model where invoking an async function returns a specification of work, which you must then start. You can start this work in different ways so that you have control over the semantics of how it executes.
C# uses a "hot task" models, where invoking the async method returns a handle to background work that has already been "kicked off". This is actually an oversimplification, because the semantics of what is actually the asynchronous thing you're awaiting can differ. But the overall concept follows this pattern.
I can't wait to have Async + ValueTask in C# 7 to help reduce the penalty of Async a bit more.