[erlang-questions] gen_server:call and hibernate
Thu May 19 02:05:07 CEST 2011
>From the facebook slides of their chat system architecture, eugene mentioned
▪ Drastically shrink memory usage with erlang:hibernate/3
▪ Throws away the call stack
▪ Minimizes the heap
▪ Enters a wait state for new messages
▪ “Jumps” into a passed-in function for a received message
▪ Perfect for a long-running, idling HTTP request handler
▪ But ... not compatible with gen_server:call (and gen_server:reply)
▪ gen_server:call has its own receive() loop
▪ hibernate() doesn’t support have an explicit timeout
▪ Fixed with a few hours and a look at gen.erl"
It took me a while to understand what he was saying. He even responded to
another persons question about this:
"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()."
I want to be able to hibernate the calling process after making a call to
the gen_server process but I can't seem to think of or know how to work
around this in an elegant way. I'm also not sure where to begin to hack
gen.erl to do this if it is possible.
Does anybody have a solution to my predicament here?
View this message in context: http://erlang.2086793.n4.nabble.com/gen-server-call-and-hibernate-tp3534336p3534336.html
Sent from the Erlang Questions mailing list archive at Nabble.com.
More information about the erlang-questions