SlideShare a Scribd company logo
LEARN U ERLANG
WEEK-5 PRESENTED BY NOLLEH
MORE ON MULTI
PROCESSING
CHAPTER. 11
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ no huge advantage if they are just functions with message
▸ process act like fridge - store / taking
fridge1() ->
receive
{From, {store, _Food}} ->
From ! {self(), ok},
fridge1();
{From, {take, _Food}} ->
From ! {self(), not_found},
fridge1();
terminate -> ok
end.
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ pass all
fridge2(FoodList) ->
receive
{From, {store, Food}} ->
From ! {self(), ok},
fridge2([Food|FoodList]);
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ pass all - 2
{From, {take, Food}} ->
case lists:member(Food, FoodList) of
true ->
From ! {self(), {ok, Food}},
fridge2(lists:delete(Food, FoodList));
false ->
From ! {self(), not_found},
fridge2(FoodList)
end;
terminate ->
ok
end.
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ test
5> Pid ! {self(), {store, bacon}}.
{<0.33.0>,{store,bacon}}
6> Pid ! {self(), {take, bacon}}.
{<0.33.0>,{take,bacon}}
7> Pid ! {self(), {take, turkey}}.
{<0.33.0>,{take,turkey}}
8> flush().
Shell got {<0.51.0>,ok}
Shell got {<0.51.0>,{ok,bacon}}
Shell got {<0.51.0>,not_found}
ok
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ makes help functions
store(Pid, Food) ->
Pid ! {self(), {store, Food}},
receive
{Pid, Msg} -> Msg
end.
take(Pid, Food) ->
Pid ! {self(), {take, Food}},
receive
{Pid, Msg} -> Msg
end.
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ using it
10> f().
ok
11> Pid = spawn(kitchen, fridge2, [[baking_soda]]).
<0.73.0>
12> kitchen:store(Pid, water).
ok
13> kitchen:take(Pid, water).
{ok,water}
14> kitchen:take(Pid, juice).
not_found
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ uh - hum. let’s wrap spawn.
start(FoodList) ->
spawn(?MODULE, fridge2, [FoodList]).
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ using it
15> f().
ok
16> c(kitchen).
{ok,kitchen}
17> Pid = kitchen:start([rhubarb, dog, hotdog]).
<0.84.0>
18> kitchen:take(Pid, dog).
{ok,dog}
19> kitchen:take(Pid, dog).
not_found
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ in normal case, what happen?
▸ A message to take food is sent from you (the shell) to the
fridge process;
▸ Your process switches to receive mode and waits for a new
message;
▸ The fridge removes the item and sends it to your process;
▸ Your process receives it and moves on with its life.
20> kitchen:take(pid, dog).
11. MORE ON MULTIPROCESSING
STATE YOUR STATE
▸ what happen?
▸ A message to take food is sent from you (the shell) to an unknown
process;
▸ Your process switches to receive mode and waits for a new
message;
▸ The unknown process either doesn't exist or doesn't expect such a
message and does nothing with it;
▸ Your shell process is stuck in receive mode.
20> kitchen:take(pid(0,250,0), dog).
11. MORE ON MULTIPROCESSING
TIMEOUT
▸ timeout
receive
Match -> Expression1
after Delay ->
Expression2
end.
11. MORE ON MULTIPROCESSING
TIMEOUT
▸ use timeout 3000
store2(Pid, Food) ->
Pid ! {self(), {store, Food}},
receive
{Pid, Msg} -> Msg
after 3000 -> timeout
end.
take2(Pid, Food) ->
Pid ! {self(), {take, Food}},
receive
{Pid, Msg} -> Msg
after 3000 -> timeout
end.
11. MORE ON MULTIPROCESSING
TIMEOUT
▸ using it
User switch command
--> k
--> s
--> c
Eshell V5.7.5 (abort with ^G)
1> c(kitchen).
{ok,kitchen}
2> kitchen:take2(pid(0,250,0), dog).
timeout
11. MORE ON MULTIPROCESSING
TIMEOUT
▸ special cases
sleep(T) ->
receive
after T -> ok
end.
flush() ->
receive
_ -> flush()
after 0 ->
ok
end.
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ give priority
important() ->
receive
{Priority, Message} when Priority > 10 ->
[Message | important()]
after 0 ->
normal()
end.
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ give priority
normal() ->
receive
{_, Message} ->
[Message | normal()]
after 0 ->
[]
end.
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ give priority
▸ before after routine is started, try to grab every message..
1> c(multiproc).
{ok,multiproc}
2> self() ! {15, high}, self() ! {7, low}, self() ! {1, low}, self() ! {17, high}.
{17,high}
3> multiproc:important().
[high,high,low,low]
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ be care!
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ be care!
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ be care!
▸ if your process has a lot of messages you never care
about, reading useful messages will actually take longer
and longer (and the processes will grow in size too).
▸ ask your self
▸ why you are getting messages you do not want ?
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ defensive measure
receive
Pattern1 -> Expression1;
Pattern2 -> Expression2;
Pattern3 -> Expression3;
...
PatternN -> ExpressionN;
Unexpected ->
io:format("unexpected message ~p~n", [Unexpected])
end.
11. MORE ON MULTIPROCESSING
SELECTIVE RECEIVES
▸ unexpected message out of the mailbox and show a
warning
▸ you can logging it
▸ more smarter way to implement priority message,..
▸ using min_heap / gb_tree (smallest.. largest..)
▸ but what if most of message has high-priority… ??
▸ optimized/1, make_ref() > R14A
ERRORS AND
PROCESSES
CHAPTER. 12
12. ERRORS AND PROCESSES
LINKS
▸ relation
myproc() ->
timer:sleep(5000),
exit(reason).
1> c(linkmon).
{ok,linkmon}
2> spawn(fun linkmon:myproc/0).
<0.52.0>
3> link(spawn(fun linkmon:myproc/0)).
true
** exception error: reason
12. ERRORS AND PROCESSES
LINKS
▸ {'EXIT', B, Reason} message can not be caught with a try ...
catch as usual
12. ERRORS AND PROCESSES
LINKS
▸ relation
chain(0) ->
receive
_ -> ok
after 2000 ->
exit("chain dies here")
end;
chain(N) ->
Pid = spawn(fun() -> chain(N-1) end),
link(Pid),
receive
_ -> ok
end.
12. ERRORS AND PROCESSES
LINKS
▸ using it
4> c(linkmon).
{ok,linkmon}
5> link(spawn(linkmon, chain, [3])).
true
** exception error: "chain dies here"
[shell] == [3] == [2] == [1] == [0]
[shell] == [3] == [2] == [1] == *dead*
[shell] == [3] == [2] == *dead*
[shell] == [3] == *dead*
[shell] == *dead*
*dead, error message shown*
[shell] <-- restarted
12. ERRORS AND PROCESSES
LINKS
▸ link/1 happens more than one step
▸ atomic
spawn_link/1-3
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ error propagation is similar with message passing, but it is
special type of message, signal.
▸ killing part is link. how about quick restarting ?
▸ system processes
process_flag(trap_exit, true)
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ example
1> process_flag(trap_exit, true).
true
2> spawn_link(fun() -> linkmon:chain(3) end).
3> receive X -> X end.
[shell] == [3] == [2] == [1] == [0]
[shell] == [3] == [2] == [1] == *dead*
[shell] == [3] == [2] == *dead*
[shell] == [3] == *dead*
[shell] <-- {'EXIT,Pid,"chain dies here"} -- *dead*
[shell] <-- still alive!
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ Let's first set the bases to experiment without a system
process
Exception source: spawn_link(fun() -> ok end)
Untrapped Result: - nothing -
Trapped Result: {'EXIT', <0.61.0>, normal}
The process exited normally, without a problem. Note that this looks
a bit like the result of catch exit(normal),
except a PID is added to the tuple to know what processed failed.
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ Let's first set the bases to experiment without a system
process
Exception source: spawn_link(fun() -> exit(reason) end)
Untrapped Result: ** exception exit: reason
Trapped Result: {'EXIT', <0.55.0>, reason}
The process has terminated for a custom reason. In this case, if there
is no trapped exit, the process crashes. Otherwise, you get the above
message
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ Let's first set the bases to experiment without a system
process
blah blah…
see Your Book. they are listed in same way..
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ exit/2 - kill another one from a distance, safely
exit(self(), normal) % same
exit(spawn_link(fun() -> timer:sleep(50000) end), normal) % no effect
exit(spawn_link(fun() -> timer:sleep(50000) end), kill)
% Trapped Result: {'EXIT', <0.58.0>, killed}
exit(self(), kill)
% Trapped Result: ** exception exit: killed
Exception source: spawn_link(fun() -> exit(kill) end)
% Untrapped Result: ** exception exit: killed
% Trapped Result: {'EXIT', <0.67.0>, kill}
12. ERRORS AND PROCESSES
IT’S A TRAP!
▸ kill
▸ you might want to brutally murder a process
▸ killed
▸ prevent cascading die
12. ERRORS AND PROCESSES
MONITORS
▸ monitor - special type of link
▸ they are unidirectional;
▸ they can be stacked.
▸ if you have 2 or 3 different libraries that you call and
they all need to know whether a process is alive or not?
▸ not stackable.. (you unlink one, you unlink them all)
12. ERRORS AND PROCESSES
MONITORS
▸ example
1> erlang:monitor(process, spawn(fun() -> timer:sleep(500) end)).
#Ref<0.0.0.77>
2> flush().
Shell got {'DOWN',#Ref<0.0.0.77>,process,<0.63.0>,normal}
ok
12. ERRORS AND PROCESSES
MONITORS
▸ recv
▸ reference : to demonitor
▸ atomic operation
{'DOWN', MonitorReference, process, Pid, Reason}
spawn_monitor/1-3
12. ERRORS AND PROCESSES
MONITORS
▸ demonitor
demonitor/1
3> {Pid, Ref} = spawn_monitor(fun() -> receive _ -> exit(boom) end
end).
{<0.73.0>,#Ref<0.0.0.100>}
4> erlang:demonitor(Ref).
true
5> Pid ! die.
die
6> flush().
ok
12. ERRORS AND PROCESSES
MONITORS
▸ demonitor
demonitor/2
8> {Pid, Ref} = spawn_monitor(fun() -> receive _ -> exit(boom) end
end).
{<0.35.0>,#Ref<0.0.0.35>}
9> Pid ! die.
die
10> erlang:demonitor(Ref, [flush, info]).
false
11> flush().
ok
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ another problem 1 - 1
start_critic() ->
spawn(?MODULE, critic, []).
judge(Pid, Band, Album) ->
Pid ! {self(), {Band, Album}},
receive
{Pid, Criticism} -> Criticism
after 2000 ->
timeout
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ another problem 1- 2
critic() ->
receive
{From, {"Rage Against the Turing Machine", "Unit Testify"}} ->
From ! {self(), "They are great!"};
{From, {"System of a Downtime", "Memoize"}} ->
From ! {self(), "They're not Johnny Crash but they're good."};
{From, {"Johnny Crash", "The Token Ring of Fire"}} ->
From ! {self(), "Simply incredible."};
{From, {_Band, _Album}} ->
From ! {self(), "They are terrible!"}
end,
critic().
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ another problem 1- 3
1> c(linkmon).
{ok,linkmon}
2> Critic = linkmon:start_critic().
<0.47.0>
3> linkmon:judge(Critic, "Genesis", "The Lambda Lies Down on
Broadway").
"They are terrible!”
4> exit(Critic, solar_storm).
true
5> linkmon:judge(Critic, "Genesis", "A trick of the Tail Recursion").
timeout
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ another problem 1- 4
start_critic2() ->
spawn(?MODULE, restarter, []).
restarter() ->
process_flag(trap_exit, true),
Pid = spawn_link(?MODULE, critic, []),
receive
{'EXIT', Pid, normal} -> % not a crash
ok;
{'EXIT', Pid, shutdown} -> % manual termination, not a crash
ok;
{'EXIT', Pid, _} ->
restarter()
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ there is no way to find the Pid of the critic !!!
start_critic2() ->
spawn(?MODULE, restarter, []).
restarter() ->
process_flag(trap_exit, true),
Pid = spawn_link(?MODULE, critic, []),
receive
{'EXIT', Pid, normal} -> % not a crash
ok;
{'EXIT', Pid, shutdown} -> % manual termination, not a crash
ok;
{'EXIT', Pid, _} ->
restarter()
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ there is no way to find the Pid of the critic !!!
▸ If the process dies, it will automatically lose its name or you
can also use unregister/1 to do it manually
▸ get list all registered process
erlang:register/2
erlang:unregister/2
erlang:registered/0 ….. in shell, regs()
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ solve problem with register
restarter() ->
process_flag(trap_exit, true),
Pid = spawn_link(?MODULE, critic, []),
register(critic, Pid),
receive
{'EXIT', Pid, normal} -> % not a crash
ok;
{'EXIT', Pid, shutdown} -> % manual termination, not a crash
ok;
{'EXIT', Pid, _} ->
restarter()
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ solve problem with register
judge2(Band, Album) ->
critic ! {self(), {Band, Album}},
Pid = whereis(critic),
receive
{Pid, Criticism} -> Criticism
after 2000 ->
timeout
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ no, it ISN’T solving problem, completely.
▸ critic: shared state / race condition
1. critic ! Message
2. critic receives
3. critic replies
4. critic dies
5. whereis fails
6. critic is restarted
7. code crashes
1. critic ! Message
2. critic receives
3. critic replies
4. critic dies
5. critic is restarted
6. whereis picks up
wrong pid
7. message never matches
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ solve problem considering pid’s differentiable 1
judge2(Band, Album) ->
Ref = make_ref(),
critic ! {self(), Ref, {Band, Album}},
receive
{Ref, Criticism} -> Criticism
after 2000 ->
timeout
end.
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ solve problem considering pid’s differentiable 2
critic2() ->
receive
{From, Ref, {"Rage Against the Turing Machine", "Unit Testify"}} ->
From ! {Ref, "They are great!"};
{From, Ref, {"System of a Downtime", "Memoize"}} ->
From ! {Ref, "They're not Johnny Crash but they're good."};
{From, Ref, {"Johnny Crash", "The Token Ring of Fire"}} ->
From ! {Ref, "Simply incredible."};
{From, Ref, {_Band, _Album}} ->
From ! {Ref, "They are terrible!"}
end,
critic2().
12. ERRORS AND PROCESSES
NAMING PROCESSES
▸ solve problem considering pid’s differentiable 3
6> c(linkmon).
{ok,linkmon}
7> linkmon:start_critic2().
<0.55.0>
8> linkmon:judge2("The Doors", "Light my Firewall").
"They are terrible!"
9> exit(whereis(critic), kill).
true
10> linkmon:judge2("Rage Against the Turing Machine",
"Unit Testify").
"They are great!"

More Related Content

What's hot

Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42
Yevhen Bobrov
 
知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips
ikeyat
 
The Ring programming language version 1.6 book - Part 28 of 189
The Ring programming language version 1.6 book - Part 28 of 189The Ring programming language version 1.6 book - Part 28 of 189
The Ring programming language version 1.6 book - Part 28 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 26 of 184
The Ring programming language version 1.5.3 book - Part 26 of 184The Ring programming language version 1.5.3 book - Part 26 of 184
The Ring programming language version 1.5.3 book - Part 26 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
Mahmoud Samir Fayed
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is Human
Alex Liu
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
Christian Baranowski
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
Christian Baranowski
 
The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212
Mahmoud Samir Fayed
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
Jonathan Waller
 
Spock framework
Spock frameworkSpock framework
Spock framework
Djair Carvalho
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
caswenson
 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212
Mahmoud Samir Fayed
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
David Chandler
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert Presentation
Mark Proctor
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boom
symbian_mgl
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
yohanbeschi
 

What's hot (20)

Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
 
The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42
 
知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips
 
The Ring programming language version 1.6 book - Part 28 of 189
The Ring programming language version 1.6 book - Part 28 of 189The Ring programming language version 1.6 book - Part 28 of 189
The Ring programming language version 1.6 book - Part 28 of 189
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196
 
The Ring programming language version 1.5.3 book - Part 26 of 184
The Ring programming language version 1.5.3 book - Part 26 of 184The Ring programming language version 1.5.3 book - Part 26 of 184
The Ring programming language version 1.5.3 book - Part 26 of 184
 
The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is Human
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84
 
The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212The Ring programming language version 1.10 book - Part 12 of 212
The Ring programming language version 1.10 book - Part 12 of 212
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert Presentation
 
Hello click click boom
Hello click click boomHello click click boom
Hello click click boom
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
 

Viewers also liked

learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10
경미 김
 
learn you some erlang - chap13 to chap14
learn you some erlang - chap13 to chap14learn you some erlang - chap13 to chap14
learn you some erlang - chap13 to chap14
경미 김
 
learn you some erlang - chap 6 to chap7
learn you some erlang - chap 6 to chap7learn you some erlang - chap 6 to chap7
learn you some erlang - chap 6 to chap7
경미 김
 
learn you some erlang - chap0 to chap2
learn you some erlang - chap0 to chap2learn you some erlang - chap0 to chap2
learn you some erlang - chap0 to chap2
경미 김
 
learn you some erlang - chap3 to chap5
learn you some erlang - chap3 to chap5learn you some erlang - chap3 to chap5
learn you some erlang - chap3 to chap5
경미 김
 
El buen uso de internet
El buen uso de internetEl buen uso de internet
El buen uso de internet
aldurwen
 
Ginecologia obstetricia
Ginecologia  obstetriciaGinecologia  obstetricia
Ginecologia obstetricia
Kevin Cázares
 
Yamal-202
Yamal-202Yamal-202
Furth klinic
Furth klinicFurth klinic
Furth klinic
kalanhoja
 
Mcollective orchestration tool 소개
Mcollective orchestration tool 소개Mcollective orchestration tool 소개
Mcollective orchestration tool 소개
태준 문
 
CEPCI
CEPCICEPCI
Cama pequena e cobertor curto - palestra 26
Cama pequena e cobertor curto - palestra 26Cama pequena e cobertor curto - palestra 26
Cama pequena e cobertor curto - palestra 26
Rogerio Sena
 
Matthieu
MatthieuMatthieu
Mindset - reprograme a mente a seu favor
Mindset - reprograme a mente a seu favorMindset - reprograme a mente a seu favor
Mindset - reprograme a mente a seu favor
Rogerio Sena
 
Combustion
Combustion Combustion
Combustion
Jowett Millan
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
Rusty Klophaus
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
JAX London
 
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Hakka Labs
 
High Performance Erlang
High  Performance  ErlangHigh  Performance  Erlang
High Performance Erlang
PerconaPerformance
 
Messaging With Erlang And Jabber
Messaging With  Erlang And  JabberMessaging With  Erlang And  Jabber
Messaging With Erlang And Jabber
l xf
 

Viewers also liked (20)

learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10learn you some erlang - chap 9 to chap10
learn you some erlang - chap 9 to chap10
 
learn you some erlang - chap13 to chap14
learn you some erlang - chap13 to chap14learn you some erlang - chap13 to chap14
learn you some erlang - chap13 to chap14
 
learn you some erlang - chap 6 to chap7
learn you some erlang - chap 6 to chap7learn you some erlang - chap 6 to chap7
learn you some erlang - chap 6 to chap7
 
learn you some erlang - chap0 to chap2
learn you some erlang - chap0 to chap2learn you some erlang - chap0 to chap2
learn you some erlang - chap0 to chap2
 
learn you some erlang - chap3 to chap5
learn you some erlang - chap3 to chap5learn you some erlang - chap3 to chap5
learn you some erlang - chap3 to chap5
 
El buen uso de internet
El buen uso de internetEl buen uso de internet
El buen uso de internet
 
Ginecologia obstetricia
Ginecologia  obstetriciaGinecologia  obstetricia
Ginecologia obstetricia
 
Yamal-202
Yamal-202Yamal-202
Yamal-202
 
Furth klinic
Furth klinicFurth klinic
Furth klinic
 
Mcollective orchestration tool 소개
Mcollective orchestration tool 소개Mcollective orchestration tool 소개
Mcollective orchestration tool 소개
 
CEPCI
CEPCICEPCI
CEPCI
 
Cama pequena e cobertor curto - palestra 26
Cama pequena e cobertor curto - palestra 26Cama pequena e cobertor curto - palestra 26
Cama pequena e cobertor curto - palestra 26
 
Matthieu
MatthieuMatthieu
Matthieu
 
Mindset - reprograme a mente a seu favor
Mindset - reprograme a mente a seu favorMindset - reprograme a mente a seu favor
Mindset - reprograme a mente a seu favor
 
Combustion
Combustion Combustion
Combustion
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
 
High Performance Erlang
High  Performance  ErlangHigh  Performance  Erlang
High Performance Erlang
 
Messaging With Erlang And Jabber
Messaging With  Erlang And  JabberMessaging With  Erlang And  Jabber
Messaging With Erlang And Jabber
 

Similar to learn you some erlang - chap11 to chap12

Containerd: Building a Container Supervisor by Michael Crosby
Containerd: Building a Container Supervisor by Michael CrosbyContainerd: Building a Container Supervisor by Michael Crosby
Containerd: Building a Container Supervisor by Michael Crosby
Docker, Inc.
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
FoundationDB
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
Aditya Tiwari
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
Jeff Frost
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
OlinData
 
Puppet: What _not_ to do
Puppet: What _not_ to doPuppet: What _not_ to do
Puppet: What _not_ to do
Puppet
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
Walter Heck
 
Week6
Week6Week6
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Ian Barber
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
 
Resilence patterns kr
Resilence patterns krResilence patterns kr
Resilence patterns kr
Jisung Ahn
 
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerOptimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
SamaySharma10
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
Mahmoud Samir Fayed
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
The Ring programming language version 1.5.2 book - Part 9 of 181
The Ring programming language version 1.5.2 book - Part 9 of 181The Ring programming language version 1.5.2 book - Part 9 of 181
The Ring programming language version 1.5.2 book - Part 9 of 181
Mahmoud Samir Fayed
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
Gonzalo Gabriel Jiménez Fuentes
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185
Mahmoud Samir Fayed
 
Doveryai, no proveryai - Introduction to tla+
Doveryai, no proveryai - Introduction to tla+Doveryai, no proveryai - Introduction to tla+
Doveryai, no proveryai - Introduction to tla+
Sandeep Joshi
 
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
Felipe Prado
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
Dan Morrill
 

Similar to learn you some erlang - chap11 to chap12 (20)

Containerd: Building a Container Supervisor by Michael Crosby
Containerd: Building a Container Supervisor by Michael CrosbyContainerd: Building a Container Supervisor by Michael Crosby
Containerd: Building a Container Supervisor by Michael Crosby
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
 
Puppet: What _not_ to do
Puppet: What _not_ to doPuppet: What _not_ to do
Puppet: What _not_ to do
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
 
Week6
Week6Week6
Week6
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
Resilence patterns kr
Resilence patterns krResilence patterns kr
Resilence patterns kr
 
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleanerOptimizing Autovacuum: PostgreSQL's vacuum cleaner
Optimizing Autovacuum: PostgreSQL's vacuum cleaner
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
The Ring programming language version 1.5.2 book - Part 9 of 181
The Ring programming language version 1.5.2 book - Part 9 of 181The Ring programming language version 1.5.2 book - Part 9 of 181
The Ring programming language version 1.5.2 book - Part 9 of 181
 
Elixir and OTP Apps introduction
Elixir and OTP Apps introductionElixir and OTP Apps introduction
Elixir and OTP Apps introduction
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185
 
Doveryai, no proveryai - Introduction to tla+
Doveryai, no proveryai - Introduction to tla+Doveryai, no proveryai - Introduction to tla+
Doveryai, no proveryai - Introduction to tla+
 
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 

Recently uploaded

GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 

Recently uploaded (20)

GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 

learn you some erlang - chap11 to chap12

  • 1. LEARN U ERLANG WEEK-5 PRESENTED BY NOLLEH
  • 3. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ no huge advantage if they are just functions with message ▸ process act like fridge - store / taking fridge1() -> receive {From, {store, _Food}} -> From ! {self(), ok}, fridge1(); {From, {take, _Food}} -> From ! {self(), not_found}, fridge1(); terminate -> ok end.
  • 4. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ pass all fridge2(FoodList) -> receive {From, {store, Food}} -> From ! {self(), ok}, fridge2([Food|FoodList]);
  • 5. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ pass all - 2 {From, {take, Food}} -> case lists:member(Food, FoodList) of true -> From ! {self(), {ok, Food}}, fridge2(lists:delete(Food, FoodList)); false -> From ! {self(), not_found}, fridge2(FoodList) end; terminate -> ok end.
  • 6. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ test 5> Pid ! {self(), {store, bacon}}. {<0.33.0>,{store,bacon}} 6> Pid ! {self(), {take, bacon}}. {<0.33.0>,{take,bacon}} 7> Pid ! {self(), {take, turkey}}. {<0.33.0>,{take,turkey}} 8> flush(). Shell got {<0.51.0>,ok} Shell got {<0.51.0>,{ok,bacon}} Shell got {<0.51.0>,not_found} ok
  • 7. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ makes help functions store(Pid, Food) -> Pid ! {self(), {store, Food}}, receive {Pid, Msg} -> Msg end. take(Pid, Food) -> Pid ! {self(), {take, Food}}, receive {Pid, Msg} -> Msg end.
  • 8. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ using it 10> f(). ok 11> Pid = spawn(kitchen, fridge2, [[baking_soda]]). <0.73.0> 12> kitchen:store(Pid, water). ok 13> kitchen:take(Pid, water). {ok,water} 14> kitchen:take(Pid, juice). not_found
  • 9. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ uh - hum. let’s wrap spawn. start(FoodList) -> spawn(?MODULE, fridge2, [FoodList]).
  • 10. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ using it 15> f(). ok 16> c(kitchen). {ok,kitchen} 17> Pid = kitchen:start([rhubarb, dog, hotdog]). <0.84.0> 18> kitchen:take(Pid, dog). {ok,dog} 19> kitchen:take(Pid, dog). not_found
  • 11. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ in normal case, what happen? ▸ A message to take food is sent from you (the shell) to the fridge process; ▸ Your process switches to receive mode and waits for a new message; ▸ The fridge removes the item and sends it to your process; ▸ Your process receives it and moves on with its life. 20> kitchen:take(pid, dog).
  • 12. 11. MORE ON MULTIPROCESSING STATE YOUR STATE ▸ what happen? ▸ A message to take food is sent from you (the shell) to an unknown process; ▸ Your process switches to receive mode and waits for a new message; ▸ The unknown process either doesn't exist or doesn't expect such a message and does nothing with it; ▸ Your shell process is stuck in receive mode. 20> kitchen:take(pid(0,250,0), dog).
  • 13. 11. MORE ON MULTIPROCESSING TIMEOUT ▸ timeout receive Match -> Expression1 after Delay -> Expression2 end.
  • 14. 11. MORE ON MULTIPROCESSING TIMEOUT ▸ use timeout 3000 store2(Pid, Food) -> Pid ! {self(), {store, Food}}, receive {Pid, Msg} -> Msg after 3000 -> timeout end. take2(Pid, Food) -> Pid ! {self(), {take, Food}}, receive {Pid, Msg} -> Msg after 3000 -> timeout end.
  • 15. 11. MORE ON MULTIPROCESSING TIMEOUT ▸ using it User switch command --> k --> s --> c Eshell V5.7.5 (abort with ^G) 1> c(kitchen). {ok,kitchen} 2> kitchen:take2(pid(0,250,0), dog). timeout
  • 16. 11. MORE ON MULTIPROCESSING TIMEOUT ▸ special cases sleep(T) -> receive after T -> ok end. flush() -> receive _ -> flush() after 0 -> ok end.
  • 17. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ give priority important() -> receive {Priority, Message} when Priority > 10 -> [Message | important()] after 0 -> normal() end.
  • 18. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ give priority normal() -> receive {_, Message} -> [Message | normal()] after 0 -> [] end.
  • 19. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ give priority ▸ before after routine is started, try to grab every message.. 1> c(multiproc). {ok,multiproc} 2> self() ! {15, high}, self() ! {7, low}, self() ! {1, low}, self() ! {17, high}. {17,high} 3> multiproc:important(). [high,high,low,low]
  • 20. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ be care!
  • 21. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ be care!
  • 22. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ be care! ▸ if your process has a lot of messages you never care about, reading useful messages will actually take longer and longer (and the processes will grow in size too). ▸ ask your self ▸ why you are getting messages you do not want ?
  • 23. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ defensive measure receive Pattern1 -> Expression1; Pattern2 -> Expression2; Pattern3 -> Expression3; ... PatternN -> ExpressionN; Unexpected -> io:format("unexpected message ~p~n", [Unexpected]) end.
  • 24. 11. MORE ON MULTIPROCESSING SELECTIVE RECEIVES ▸ unexpected message out of the mailbox and show a warning ▸ you can logging it ▸ more smarter way to implement priority message,.. ▸ using min_heap / gb_tree (smallest.. largest..) ▸ but what if most of message has high-priority… ?? ▸ optimized/1, make_ref() > R14A
  • 26. 12. ERRORS AND PROCESSES LINKS ▸ relation myproc() -> timer:sleep(5000), exit(reason). 1> c(linkmon). {ok,linkmon} 2> spawn(fun linkmon:myproc/0). <0.52.0> 3> link(spawn(fun linkmon:myproc/0)). true ** exception error: reason
  • 27. 12. ERRORS AND PROCESSES LINKS ▸ {'EXIT', B, Reason} message can not be caught with a try ... catch as usual
  • 28. 12. ERRORS AND PROCESSES LINKS ▸ relation chain(0) -> receive _ -> ok after 2000 -> exit("chain dies here") end; chain(N) -> Pid = spawn(fun() -> chain(N-1) end), link(Pid), receive _ -> ok end.
  • 29. 12. ERRORS AND PROCESSES LINKS ▸ using it 4> c(linkmon). {ok,linkmon} 5> link(spawn(linkmon, chain, [3])). true ** exception error: "chain dies here" [shell] == [3] == [2] == [1] == [0] [shell] == [3] == [2] == [1] == *dead* [shell] == [3] == [2] == *dead* [shell] == [3] == *dead* [shell] == *dead* *dead, error message shown* [shell] <-- restarted
  • 30. 12. ERRORS AND PROCESSES LINKS ▸ link/1 happens more than one step ▸ atomic spawn_link/1-3
  • 31. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ error propagation is similar with message passing, but it is special type of message, signal. ▸ killing part is link. how about quick restarting ? ▸ system processes process_flag(trap_exit, true)
  • 32. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ example 1> process_flag(trap_exit, true). true 2> spawn_link(fun() -> linkmon:chain(3) end). 3> receive X -> X end. [shell] == [3] == [2] == [1] == [0] [shell] == [3] == [2] == [1] == *dead* [shell] == [3] == [2] == *dead* [shell] == [3] == *dead* [shell] <-- {'EXIT,Pid,"chain dies here"} -- *dead* [shell] <-- still alive!
  • 33. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ Let's first set the bases to experiment without a system process Exception source: spawn_link(fun() -> ok end) Untrapped Result: - nothing - Trapped Result: {'EXIT', <0.61.0>, normal} The process exited normally, without a problem. Note that this looks a bit like the result of catch exit(normal), except a PID is added to the tuple to know what processed failed.
  • 34. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ Let's first set the bases to experiment without a system process Exception source: spawn_link(fun() -> exit(reason) end) Untrapped Result: ** exception exit: reason Trapped Result: {'EXIT', <0.55.0>, reason} The process has terminated for a custom reason. In this case, if there is no trapped exit, the process crashes. Otherwise, you get the above message
  • 35. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ Let's first set the bases to experiment without a system process blah blah… see Your Book. they are listed in same way..
  • 36. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ exit/2 - kill another one from a distance, safely exit(self(), normal) % same exit(spawn_link(fun() -> timer:sleep(50000) end), normal) % no effect exit(spawn_link(fun() -> timer:sleep(50000) end), kill) % Trapped Result: {'EXIT', <0.58.0>, killed} exit(self(), kill) % Trapped Result: ** exception exit: killed Exception source: spawn_link(fun() -> exit(kill) end) % Untrapped Result: ** exception exit: killed % Trapped Result: {'EXIT', <0.67.0>, kill}
  • 37. 12. ERRORS AND PROCESSES IT’S A TRAP! ▸ kill ▸ you might want to brutally murder a process ▸ killed ▸ prevent cascading die
  • 38. 12. ERRORS AND PROCESSES MONITORS ▸ monitor - special type of link ▸ they are unidirectional; ▸ they can be stacked. ▸ if you have 2 or 3 different libraries that you call and they all need to know whether a process is alive or not? ▸ not stackable.. (you unlink one, you unlink them all)
  • 39. 12. ERRORS AND PROCESSES MONITORS ▸ example 1> erlang:monitor(process, spawn(fun() -> timer:sleep(500) end)). #Ref<0.0.0.77> 2> flush(). Shell got {'DOWN',#Ref<0.0.0.77>,process,<0.63.0>,normal} ok
  • 40. 12. ERRORS AND PROCESSES MONITORS ▸ recv ▸ reference : to demonitor ▸ atomic operation {'DOWN', MonitorReference, process, Pid, Reason} spawn_monitor/1-3
  • 41. 12. ERRORS AND PROCESSES MONITORS ▸ demonitor demonitor/1 3> {Pid, Ref} = spawn_monitor(fun() -> receive _ -> exit(boom) end end). {<0.73.0>,#Ref<0.0.0.100>} 4> erlang:demonitor(Ref). true 5> Pid ! die. die 6> flush(). ok
  • 42. 12. ERRORS AND PROCESSES MONITORS ▸ demonitor demonitor/2 8> {Pid, Ref} = spawn_monitor(fun() -> receive _ -> exit(boom) end end). {<0.35.0>,#Ref<0.0.0.35>} 9> Pid ! die. die 10> erlang:demonitor(Ref, [flush, info]). false 11> flush(). ok
  • 43. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ another problem 1 - 1 start_critic() -> spawn(?MODULE, critic, []). judge(Pid, Band, Album) -> Pid ! {self(), {Band, Album}}, receive {Pid, Criticism} -> Criticism after 2000 -> timeout end.
  • 44. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ another problem 1- 2 critic() -> receive {From, {"Rage Against the Turing Machine", "Unit Testify"}} -> From ! {self(), "They are great!"}; {From, {"System of a Downtime", "Memoize"}} -> From ! {self(), "They're not Johnny Crash but they're good."}; {From, {"Johnny Crash", "The Token Ring of Fire"}} -> From ! {self(), "Simply incredible."}; {From, {_Band, _Album}} -> From ! {self(), "They are terrible!"} end, critic().
  • 45. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ another problem 1- 3 1> c(linkmon). {ok,linkmon} 2> Critic = linkmon:start_critic(). <0.47.0> 3> linkmon:judge(Critic, "Genesis", "The Lambda Lies Down on Broadway"). "They are terrible!” 4> exit(Critic, solar_storm). true 5> linkmon:judge(Critic, "Genesis", "A trick of the Tail Recursion"). timeout
  • 46. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ another problem 1- 4 start_critic2() -> spawn(?MODULE, restarter, []). restarter() -> process_flag(trap_exit, true), Pid = spawn_link(?MODULE, critic, []), receive {'EXIT', Pid, normal} -> % not a crash ok; {'EXIT', Pid, shutdown} -> % manual termination, not a crash ok; {'EXIT', Pid, _} -> restarter() end.
  • 47. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ there is no way to find the Pid of the critic !!! start_critic2() -> spawn(?MODULE, restarter, []). restarter() -> process_flag(trap_exit, true), Pid = spawn_link(?MODULE, critic, []), receive {'EXIT', Pid, normal} -> % not a crash ok; {'EXIT', Pid, shutdown} -> % manual termination, not a crash ok; {'EXIT', Pid, _} -> restarter() end.
  • 48. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ there is no way to find the Pid of the critic !!! ▸ If the process dies, it will automatically lose its name or you can also use unregister/1 to do it manually ▸ get list all registered process erlang:register/2 erlang:unregister/2 erlang:registered/0 ….. in shell, regs()
  • 49. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ solve problem with register restarter() -> process_flag(trap_exit, true), Pid = spawn_link(?MODULE, critic, []), register(critic, Pid), receive {'EXIT', Pid, normal} -> % not a crash ok; {'EXIT', Pid, shutdown} -> % manual termination, not a crash ok; {'EXIT', Pid, _} -> restarter() end.
  • 50. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ solve problem with register judge2(Band, Album) -> critic ! {self(), {Band, Album}}, Pid = whereis(critic), receive {Pid, Criticism} -> Criticism after 2000 -> timeout end.
  • 51. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ no, it ISN’T solving problem, completely. ▸ critic: shared state / race condition 1. critic ! Message 2. critic receives 3. critic replies 4. critic dies 5. whereis fails 6. critic is restarted 7. code crashes 1. critic ! Message 2. critic receives 3. critic replies 4. critic dies 5. critic is restarted 6. whereis picks up wrong pid 7. message never matches
  • 52. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ solve problem considering pid’s differentiable 1 judge2(Band, Album) -> Ref = make_ref(), critic ! {self(), Ref, {Band, Album}}, receive {Ref, Criticism} -> Criticism after 2000 -> timeout end.
  • 53. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ solve problem considering pid’s differentiable 2 critic2() -> receive {From, Ref, {"Rage Against the Turing Machine", "Unit Testify"}} -> From ! {Ref, "They are great!"}; {From, Ref, {"System of a Downtime", "Memoize"}} -> From ! {Ref, "They're not Johnny Crash but they're good."}; {From, Ref, {"Johnny Crash", "The Token Ring of Fire"}} -> From ! {Ref, "Simply incredible."}; {From, Ref, {_Band, _Album}} -> From ! {Ref, "They are terrible!"} end, critic2().
  • 54. 12. ERRORS AND PROCESSES NAMING PROCESSES ▸ solve problem considering pid’s differentiable 3 6> c(linkmon). {ok,linkmon} 7> linkmon:start_critic2(). <0.55.0> 8> linkmon:judge2("The Doors", "Light my Firewall"). "They are terrible!" 9> exit(whereis(critic), kill). true 10> linkmon:judge2("Rage Against the Turing Machine", "Unit Testify"). "They are great!"