fez icon indicating copy to clipboard operation
fez copied to clipboard

RFC 2: Async

Open kjnilsson opened this issue 7 years ago • 4 comments

All IO in erlang is "async" (non blocking) so for that kind of code async can effectively be erased.

In the case of Async.Start* we could potentially compile these to spawn new processes to provide parallelism. It would require careful design but may be worthwhile.

kjnilsson avatar Jul 04 '17 13:07 kjnilsson

IO isn't async for the process that is calling it by default. I'm not sure how the Async IO operations work in fsharp but if you need to look into doing them in more of an async manner you can.

This is the blocking code: https://github.com/erlang/otp/blob/maint/lib/stdlib/src/io.erl#L572

https://github.com/elixir-lang/elixir/blob/master/lib/logger/lib/logger/backends/console.ex https://medium.com/@olafura/faster-elixir-logger-part-1-8f5424396943 https://medium.com/@olafura/faster-elixir-logger-part-2-ddb328eb31f4

olafura avatar Oct 23 '17 18:10 olafura

Thanks for the comments. Fsharp async (and c# async for that matter) is mostly a hack around the fact that .NET allows you to block the calling thread when doing io. Erlang doesn’t allow this as naturally there is no direct interaction with threads. So when I said non blocking above I meant it in the .NET sense. :) I admit that isn’t clear.

Async can also be used to dispatch work on the threadpool which has a better translation to erlang.

I’ve implemented this partly already where async.start will spawn a new process to execute a computation on.

kjnilsson avatar Oct 23 '17 19:10 kjnilsson

Couldn't you go for Hopac now that you have a chance to do it well? It's a much stronger, more stable abstraction than Async.

haf avatar May 19 '18 09:05 haf

See my comment in #34

kjnilsson avatar May 19 '18 09:05 kjnilsson