4 ms·
> Personally I find Actor model concurrency so much easier to deal with (e.g. Erlang). The rules seem significantly more straightforward and easier to deal with
by apta 7y ago
> Personally I find Actor model concurrency so much easier to deal with (e.g. Erlang). The rules seem significantly more straightforward and easier to deal with mentally.
I haven't used Erlang, but how does it deal with blocking calls? Say an actor decides to make a call to the DB. Will the runtime block the current thread the actor is running on?
The other alternative to explicit async/await, which permeates the entire call stack as you pointed out, is to have green threads, like Java's upcoming fibers (see project Loom). The runtime automatically swaps out the current fiber once it makes a blocking call and switches in another non-blocking fiber to continue making progress.
- Polycryptus 7y agoErlang's VM runs a scheduler on top of a number of OS threads. If an actor blocks, that actor won't be scheduled to run until the blocking call is finished, but you won't consume a whole OS threads, and other actors will be able to run while waiting for completion.