-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartial_Ordering_Reactor.lf
40 lines (40 loc) · 1.06 KB
/
Partial_Ordering_Reactor.lf
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
target Cpp
reactor Sender {
output msg: int;
logical action sendMsg;
reaction(startup) -> sendMsg{=
sendMsg.schedule(0ms);
=}
reaction(sendMsg) -> msg, sendMsg {=
msg.set(1);
reactor::log::Info()<<"Message broadcasted";
sendMsg.schedule(1s);
=}
}
reactor receiver(id: int = 0) {
input rcvMsg: int;
state receivedMessage: int;
reaction(rcvMsg) {=
reactor::log::Info()<<"Message Recieved on receiver: "<<id;
=}
}
reactor medium(id: int = 0){
input rcvMsg: int;
output sendMsg: int;
reaction(rcvMsg) -> sendMsg {=
reactor::log::Info()<<"Message Recieved on Medium: "<<id;
sendMsg.set(0);
reactor::log::Info()<<"Message Sent on Medium: "<<id;
=}
}
main reactor {
receiver0 = new receiver(id = 1);
receiver1 = new receiver(id = 2);
medium3 = new medium(id = 3);
medium4 = new medium(id = 4);
sender1 = new Sender();
sender1.msg -> medium3.rcvMsg;
sender1.msg -> medium4.rcvMsg;
medium3.sendMsg->receiver0.rcvMsg;
medium4.sendMsg->receiver1.rcvMsg;
}