[erlang-questions] Re: Erlang at Facebook - hibernation and gen_server

Davide Marquês nesrait@REDACTED
Mon Jul 13 06:24:10 CEST 2009

On Wed, Jul 8, 2009 at 12:16 PM, eletuchy@REDACTED <eletuchy@REDACTED>wrote:

> The incompatibility is on the client side (gen:call), not the server
> side (gen_server:handle_call). There's a receive() loop inside
> gen:call that prevents a client from hibernating between dispatching
> the $call message and getting back the gen_server:reply().

Thanks for the feedback! Got it! :)

It seems it's just a matter of (famous last words):
 - using erlang:send_after/3 to get the process to wake up from
   hibernation after the given Timeout;
 - hibernating the client process (with proc_lib:hibernate/3) while waiting
for the reply
 - turn the control (after waking up) to a function that's ready to handle
the reply and
   the erlang:send_after/3's timeout we had set up before hibernating.

Trying this out now... results later on. :)


More information about the erlang-questions mailing list