[erlang-questions] STM vs Actor Model?
Jesper Louis Andersen
jesper.louis.andersen@REDACTED
Tue May 6 15:23:42 CEST 2014
On Tue, May 6, 2014 at 3:12 PM, Bin Wang <wbin00@REDACTED> wrote:
> And for "block the actor", I didn't mean the messages passing are not
> asynced. But if we write a "handle_call" in a "gen_server" that takes
> a long time to compute things for example. Then the other requests
> behind this long time request are blocked (if it wants to get some
> information from the "gen_server").
>
No. Not necessarily. You could return {noreply, State} in your
handle_call/3 and then spawn a background worker to do the processing. When
data comes back you can respond with gen_server:reply(From, Result). This
avoids the "head of line blocking".
--
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140506/168f9fe6/attachment.htm>
More information about the erlang-questions
mailing list