[erlang-questions] gen_fsm and active sockets

igwan igwan@REDACTED
Tue Jan 15 22:27:02 CET 2008


Dave Smith wrote :
[...]
> Agreed -- processes and # of messages both grow with approach 1.
> However, processes and messages are a primary paradigm in Erlang; it
> would be remiss of me to not consider using them to solve this
> problem, I think.
>   


Well it depends on what additional problem you want to solve when 
dispatching messages through one process, while you could receive them 
directly on the processes that needs the data. It's right that processes 
are cheap in Erlang but "Don't buy too many spades" says the manual. 
Gen_fsm are also meant to receive plain messages, not only events. It 
just seems natural to have each one fsm fully handle its own socket.

[...]
> Actually I believe it's more expensive than just a straight function
> call -- it boils down to a call to "apply" unless I'm mistaken. Not
> sure how the overhead of invoking apply compares to message passing...
>   

Receiving an event in a gen_fsm is for sure much more slower than a 
direct "apply". The OTP behaviour does a bunch of things ... before it 
eventually does an "apply" in your callback module. :)


--
igwan



More information about the erlang-questions mailing list