[erlang-questions] gen_server call when return value isn't wanted

Bengt Kleberg bengt.kleberg@REDACTED
Fri Feb 11 07:40:35 CET 2011


There is no difference in the time it takes to complete the function
call if you have no assignment or if you assign to '_'.

If it is not the time you can save, by not waiting for the
gen_fsm:call/2 to return that interest you, I suggest using no

If you want to continue asynchronous in the (now) calling process you
will need a new function using cast, or as you suggest, spawning a new
process before calling the old function. I would spawn if this only
happens once, but have a new function if it is done more than once.


On Fri, 2011-02-11 at 04:37 +0100, James Aimonetti wrote:
> I have a gen_server function, that as part of the body does a DB save, 
> and returns the saved version of the data.
> save_data(Data) ->
>    gen_server:call(?SERVER, {save_data, Data}).
> Occasionally I don't care about the result of the save and was wondering 
> about couple of ideas.
> Is there a difference to the compiler in doing
> ...
> my_server:save_data(Stuff),
> ...
> versus
> ...
> _ = my_server:save_data(Stuff),
> ...
> or should I just create a version of save_data/1 that uses cast instead? 
> Perhaps spawn the save_data/1 call?

More information about the erlang-questions mailing list