服务器模块              返回模块
-----------------            ---------------
gen_server:start_link  -----> Module:init/1
gen_server:call
gen_server:multi_call  -----> Module:handle_call/3
gen_server:cast
gen_server:abcast      -----> Module:handle_cast/2
-                         -----> Module:handle_info/2
-                         -----> Module:terminate/2
-                         -----> Module:code_change/3

 

 

 

一、函数start_link——创建一个gen_server进程,并注册为Module.
start_link(Module, Args, Options) -> Result
start_link(ServerName, Module, Args, Options) -> Result

各参数类型
ServerName = {local,Name} | {global,GlobalName}   {Name = atom(), GlobalName = term()}
Module = atom()
Args = term()
Options = [Option]
 Option = {debug,Dbgs} | {timeout,Time} | {spawn_opt,SOpts}
  Dbgs = [Dbg] "Dbg = trace | log | statistics | {log_to_file,FileName} | {install,{Func,FuncState}}"
  SOpts = [term()]
返回值= {ok,Pid} | ignore | {error,Error}
 Pid = pid()
 Error = {already_started,Pid} | term()
: 如果成功创建并被初使化返回{ok, Pid},则Pid为这个进程的pid;如果已经存在Module这个进程,返回{error, ,{already_started,Pid}},则Pid为这个进程的pid.


 

 

相关文章:

  • 2022-01-23
  • 2021-12-15
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
猜你喜欢
  • 2021-05-24
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
相关资源
相似解决方案