-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_par_debug.erl
More file actions
40 lines (36 loc) · 1.35 KB
/
Copy pathtest_par_debug.erl
File metadata and controls
40 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-module(test_par_debug).
-compile(export_all).
test() ->
%% Simple parallel: 2 branches
Bytecode = [
{par_fork, [1, 3]},
{task_exec, task_a},
{done},
{task_exec, task_b},
{done},
{join_wait, all}
],
ExecState0 = wf_exec:new(Bytecode),
io:format("Initial state:~n IP: ~p~n Tokens: ~p~n", [
ExecState0#exec_state.ip,
maps:size(ExecState0#exec_state.tokens)
]),
Result = wf_exec:run(ExecState0, 10, undefined),
io:format("Result: ~p~n", [Result]),
case Result of
{done, ExecState1} ->
io:format("Final state:~n IP: ~p~n Tokens: ~p~n Status: ~p~n", [
ExecState1#exec_state.ip,
maps:to_list(ExecState1#exec_state.tokens),
ExecState1#exec_state.status
]),
lists:foreach(fun({TokenId, Token}) ->
io:format(" Token ~p: IP=~p, Status=~p~n", [TokenId, Token#token.ip, Token#token.status])
end, maps:to_list(ExecState1#exec_state.tokens));
{yield, ExecState1} ->
io:format("Yielded after ~p steps~n", [ExecState1#exec_state.step_count]),
io:format("Current state:~n IP: ~p~n Tokens: ~p~n", [
ExecState1#exec_state.ip,
maps:to_list(ExecState1#exec_state.tokens)
])
end.