add demo docs
This commit is contained in:
parent
5d63adb2a7
commit
73f299d3f0
12 changed files with 243 additions and 9 deletions
20
demo/kitchen-sink/docs/erlang.erl
Normal file
20
demo/kitchen-sink/docs/erlang.erl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%% A process whose only job is to keep a counter.
|
||||
%% First version
|
||||
-module(counter).
|
||||
-export([start/0, codeswitch/1]).
|
||||
|
||||
start() -> loop(0).
|
||||
|
||||
loop(Sum) ->
|
||||
receive
|
||||
{increment, Count} ->
|
||||
loop(Sum+Count);
|
||||
{counter, Pid} ->
|
||||
Pid ! {counter, Sum},
|
||||
loop(Sum);
|
||||
code_switch ->
|
||||
?MODULE:codeswitch(Sum)
|
||||
% Force the use of 'codeswitch/1' from the latest MODULE version
|
||||
end.
|
||||
|
||||
codeswitch(Sum) -> loop(Sum).
|
||||
Loading…
Add table
Add a link
Reference in a new issue