Mickael Remond mickael.remond@REDACTED
Wed Dec 17 10:40:44 CET 2003

* Martin J. Logan <mlogan@REDACTED> [2003-12-15 17:35:33 -0600]:

> On Mon, 2003-12-15 at 17:04, Inswitch Solutions - Erlang Evaluation
> wrote:
> > Hi Lennart,
> > 
> > Suppose Pid0 is the gen_server Pid
> > 
> > I execute in two different processes (clients):
> > - Pid1 gen_server:call to Pid0 gen_server
> > - Pid2 gen_server:call to Pid0 gen_server
> > 
> > Is the gen_server blocked while processing Pid1 or Pid2 request?
> The gen server is a single process i.e a single "thread". Consequently
> if you make a call from pid1 the gen server is going to service that
> request and send back a response before it ever pulls the request sent
> by pid2 out of its(pid0) mailbox. This is assuming that the request made
> by pid1 got arrived in the mailbox of pid0 first. Basically the first
> request will be totally serviced and the the second request will be
> serviced in the same manner. 

Gen_server are basically used to protect resources. Those resources are
for example often stored in the gen_server state.

You should ask you one question:
Do you really need a gen_server in the situation you are describing ?

Most of the time, when you are thinking about having a "parallel
gen_server", you do not need a gen_server. Try to see if a simple
function call from each process (Pid1 and Pid2 in your example) are not
what you really want.


Mickaël Rémond

More information about the erlang-questions mailing list