What is the difference between gen_server: cast to gen_server: abcast

When viewing the abcast man page ,
and cast personal page , I could not understand what is the difference between the two.
Maybe someone will clarify this for me.

thanks

+7
erlang otp gen-server
source share
1 answer

There are three differences between gen_server:cast/2 and gen_server:abcast/2,3 :

  • gen_server:abcast/3 accepts a list of target nodes that determine where gen_server instances registered by the specified name can be found, and gen_server:abcast/2 sent to the list [node() | nodes()] [node() | nodes()] , whereas gen_server:cast/2 can access only one gen_server instance.
  • To identify the target server, gen_server:abcast/2,3 only accepts the name as an atom, while gen_server:cast/2 can accept an atom, pid, or for the global and via parameters, any Erlang term.
  • gen_server:abcast/2,3 returns abcast , whereas gen_server:cast/2 returns ok .

The first difference is the most important because it allows asynchronous broadcasting (i.e. abcast ) for a set of gen_server instances for a set of nodes.

+9
source share

All Articles