erlang之exit/1,exit/2探索
来源:互联网 发布:淘宝网泳装 编辑:程序博客网 时间:2024/06/05 03:51
-module(time).
-export([start/2, stop/0, stop/1, cancel/1]).
start(Time,Fun) ->
spawn(fun() -> time(Time,Fun) end).
stop(Pid) ->
%%exit(Pid, normal). %% NO
%% If Reason is the atom normal, Pid will not exit.
%% If it is trapping exits, the exit signal is
%% transformed into a message {'EXIT', From, normal}
%% and delivered to its message queue.
exit(Pid, kill). %%YES
%% If Reason is the atom kill, that is if
%% exit(Pid, kill) is called, an untrappable
%% exit signal is sent to Pid which will
%% unconditionally exit with exit reason killed.
stop() -> %% YES 停掉调用time:stop()的进程,达不到停止要停止的进程的要求,是否normal无关
%%exit(normal).
exit(shutdown).
cancel(Pid) ->
Pid ! cancel.
time(Time,Fun) ->
receive cancel ->
void
after Time ->
Fun(),
%%stop(), %% OK
%%exit(normal), %% OK
time(Time,Fun)
end.
timer(Time,Fun) ->
Fun(),
timer:sleep(Time),
io:format("here~n"),
%%stop(), %% OK
%%exit(normal), %% OK
time(Time,Fun).
-export([start/2, stop/0, stop/1, cancel/1]).
start(Time,Fun) ->
spawn(fun() -> time(Time,Fun) end).
stop(Pid) ->
%%exit(Pid, normal). %% NO
%% If Reason is the atom normal, Pid will not exit.
%% If it is trapping exits, the exit signal is
%% transformed into a message {'EXIT', From, normal}
%% and delivered to its message queue.
exit(Pid, kill). %%YES
%% If Reason is the atom kill, that is if
%% exit(Pid, kill) is called, an untrappable
%% exit signal is sent to Pid which will
%% unconditionally exit with exit reason killed.
stop() -> %% YES 停掉调用time:stop()的进程,达不到停止要停止的进程的要求,是否normal无关
%%exit(normal).
exit(shutdown).
cancel(Pid) ->
Pid ! cancel.
time(Time,Fun) ->
receive cancel ->
void
after Time ->
Fun(),
%%stop(), %% OK
%%exit(normal), %% OK
time(Time,Fun)
end.
timer(Time,Fun) ->
Fun(),
timer:sleep(Time),
io:format("here~n"),
%%stop(), %% OK
%%exit(normal), %% OK
time(Time,Fun).
- erlang之exit/1,exit/2探索
- 谈谈erlang:exit/2
- exit
- exit
- exit
- Exit()
- exit
- exit
- exit()
- exit
- exit
- exit()
- exit
- Exit()
- exit
- exit(0) exit(1)/exit(-1)
- exit(0),exit(1),exit-1)
- linux学习之十二---exit(0)&exit(1)&return
- HttpModule 介绍
- C#中的异步调用及异步设计模式(一)
- Google SVN
- set
- 书写SQL注意的一些事项
- erlang之exit/1,exit/2探索
- metro performence tips
- Android模拟器遭遇Address family not supported by protocol异常
- Linux下一些常见的shell 命令
- C#网络应用|理解Scoket协议 |新手教程
- 在AMD的WIN7上搭建IOS开发环境(mac 10.6.8 + xcode 4.2)
- C#中的异步调用及异步设计模式(二)——基于 IAsyncResult 的异步设计模式
- ogre学习小结
- 图像处理:双线性差值的另一种处理方法