Skip to content

Commit c687a13

Browse files
committed
Update README for chapter 13
1 parent 1adec37 commit c687a13

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Diff for: chapter_13/README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Solution in [exercise_4/](exercise_4).
1818

1919
**5. Write a function that spawns and monitors several processes. If any monitored processes dies, restart the monitored process.**
2020

21-
Solution in [exercise_5/](exercise_5). The code is in `workers.erl`
21+
Solution in [exercise_5/](exercise_5). The code is in `worker_supervisor.erl`
2222

2323
Example usage:
2424

@@ -36,9 +36,24 @@ I'm still running
3636
3> [{Pid, _, _, _}|_] = WorkerData.
3737
% And kill it to verify it got restarted
3838
4> exit(Pid, test).
39-
1> workers:spawn_and_restart_workers(workers:definition()).
4039
```
4140

4241
**6. Write a function that spawns and monitors several processes. If any monitored processes dies, kill all the processes and restart them.**
4342

44-
Solution in [exercise_6/](exercise_6).
43+
Solution in [exercise_6/](exercise_6). The code is in `worker_supervisor.erl`
44+
45+
```
46+
erlc worker_supervisors.erl
47+
erl
48+
% Start the supervisor with a list of children
49+
1> SupervisorPid = worker_supervisor:start(worker_supervisor:definition()).
50+
I'm still running
51+
I'm still running
52+
% Get one of the child processes
53+
2> WorkerData = worker_supervisor:get_workers(SupervisorPid).
54+
[{<0.41.0>,#Ref<0.0.4.148>,-576460742360537501,{worker_supervisor,test,[]}},
55+
{<0.42.0>,#Ref<0.0.4.149>,-576460742360529319,{worker_supervisor,test,[]}}]
56+
3> [{Pid, _, _, _}|_] = WorkerData.
57+
% And kill it to verify it got restarted
58+
4> exit(Pid, test).
59+
```

0 commit comments

Comments
 (0)