Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 2: Async #22

Open
kjnilsson opened this issue Jul 4, 2017 · 4 comments
Open

RFC 2: Async #22

kjnilsson opened this issue Jul 4, 2017 · 4 comments
Labels

Comments

@kjnilsson
Copy link
Owner

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 kjnilsson added the rfc label Jul 4, 2017
kjnilsson added a commit that referenced this issue Jul 5, 2017
@olafura
Copy link

olafura commented Oct 23, 2017

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

@kjnilsson
Copy link
Owner Author

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.

@haf
Copy link

haf commented May 19, 2018

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.

@kjnilsson
Copy link
Owner Author

See my comment in #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants