Commit | Line | Data |
---|---|---|
79a2bc14 SK |
1 | -module(life_lib). |
2 | ||
3 | -export([cast_one2all/2 | |
4 | ,cast_all2one/2 | |
5 | ]). | |
6 | ||
7 | ||
8 | % Cast all messages to one destination | |
9 | cast_all2one(_, []) -> ok; | |
10 | cast_all2one(Server, [Msg | Msgs]) -> | |
11 | ok = gen_server:cast(Server, Msg), | |
12 | cast_all2one(Server, Msgs). | |
13 | ||
14 | ||
15 | % Cast one message to all destinations | |
16 | cast_one2all([], _) -> ok; | |
17 | cast_one2all([Server | Servers], Msg) -> | |
18 | ok = gen_server:cast(Server, Msg), | |
19 | cast_one2all(Servers, Msg). | |
20 |