No subject

Tue Jan 4 10:43:02 CET 2005

Some of the answers
On Tue, 2005-01-04 at 10:58 +0600, Casper wrote:
Hi All,
> It's me again with a list of questions.
> Gen_server:
> 1) Does gen_server execute code synchronously?
> 2) Even though gen_server Cast is a asynchronous request, in terms of
> Gen_server, it's synchronous code execution, right?
> 3) So if I need to process things in parallel in the server side, how can I
> do it?
> 4) Then what happens to the Gen_server State, if parallel execution can
> happen?
> 1 & 2.  This was one of the things that got me as well.
A genserver will process sequentially - but globally (read "in the big
system") the other process that made the cast can asyncronously continue
to process.  By having many "seperate processes" you obtain the
asyncronous processing.
Quite a clever idea from the ericson guys - call - I will stand and wait
for an answer - cast - here is the job do it while I go off and do
something else

3.  Multiple processes or gen servers.  Having multiple "processing
streams" this can be done with a gen_server spawning new gen_servers as
"workers" as part of a nice supervision tree.  Example:  Server accepting
client connections - for each connection - spawn a new gen_server - this
gen_server "worker" will process all requests in sequence whether this is
call or cast - but for another client connection - spawn a seperate
gen_server "worker" which will process independently and in "parallel" to
the first gen_server "worker"

4.  The state is per gen_server - depending on your needs - I see the
state as a whiteboard where I keep "notes" on what is happening in the
gen_server - if you need inter gen_server communication  then work through
a "parent" gen_server that tracks the children and that informs you of the
location (pid) of the other processes.

For the answers below  I am not a telco guy, yet!  just use some of their
> 1) As I can see Gen_fsm starts its own process for each state machine.
> 2) Because of that if I use Gen_fsm to maintain Call (Telecom switch or PBX
> kind of system) handling, for each Call a new process starts.
> 3) Is this a good method?
> 4) Or rather should I use an Erlang Dict to have Call Circuit State
> and update each machine in every call event?
> All of above are not questions, some are statements. If you can advice
me in
> terms of Best Erlang Practice, I really appreciate.
> Also I wonder if any of you out there, who has done Telecom platforms in
> Erlang, is willing to provide consultation to me.
> Thanks in advance!
> Eranga
Danie Schutte <danie@REDACTED>
Erlang Financial Systems

More information about the erlang-questions mailing list