AICells 4 роки тому
джерело
коміт
58cd02f78a
2 змінених файлів з 47 додано та 2 видалено
  1. +23
    -1
      src/gen_ipc.erl
  2. +24
    -1
      src/gen_srv.erl

+ 23
- 1
src/gen_ipc.erl Переглянути файл

@ -10,7 +10,7 @@
start/3, start/4, start_link/3, start_link/4
, start_monitor/3, start_monitor/4
, stop/1, stop/3
, cast/2
, cast/2, send/2
, abcast/2, abcast/3
, call/2, call/3
, send_request/2, wait_response/1, wait_response/2, check_response/2
@ -640,6 +640,28 @@ cast(Dest, Msg) ->
catch _:_ -> ok
end.
-spec send(ServerRef :: serverRef(), Msg :: term()) -> ok.
send({global, Name}, Msg) ->
try global:send(Name, Msg),
ok
catch _:_ -> ok
end;
send({via, RegMod, Name}, Msg) ->
try RegMod:send(Name, Msg),
ok
catch _:_ -> ok
end;
send({Name, Node} = Dest, Msg) when is_atom(Name), is_atom(Node) ->
try erlang:send(Dest, Msg),
ok
catch _:_ -> ok
end;
send(Dest, Msg) ->
try erlang:send(Dest, Msg),
ok
catch _:_ -> ok
end.
%% 异步广播,不返回任何内容,只是发送“ n”祈祷
abcast(Name, Msg) when is_atom(Name) ->
doAbcast([node() | nodes()], Name, Msg).

+ 24
- 1
src/gen_srv.erl Переглянути файл

@ -12,7 +12,7 @@
, stop/1, stop/3
, call/2, call/3
, send_request/2, wait_response/2, check_response/2
, cast/2, reply/1, reply/2
, cast/2, send/2, reply/1, reply/2
, abcast/2, abcast/3
, multi_call/2, multi_call/3, multi_call/4
, enter_loop/3, enter_loop/4, enter_loop/5
@ -466,6 +466,29 @@ cast(Dest, Msg) ->
catch _:_ -> ok
end.
-spec send(ServerRef :: serverRef(), Msg :: term()) -> ok.
send({global, Name}, Msg) ->
try global:send(Name, Msg),
ok
catch _:_ -> ok
end;
send({via, RegMod, Name}, Msg) ->
try RegMod:send(Name, Msg),
ok
catch _:_ -> ok
end;
send({Name, Node} = Dest, Msg) when is_atom(Name), is_atom(Node) ->
try erlang:send(Dest, Msg),
ok
catch _:_ -> ok
end;
send(Dest, Msg) ->
try erlang:send(Dest, Msg),
ok
catch _:_ -> ok
end.
%% 广 n
abcast(Name, Msg) when is_atom(Name) ->
doAbcast([node() | nodes()], Name, Msg).

Завантаження…
Відмінити
Зберегти