-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into single-threaded
- Loading branch information
Showing
5 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
target C { | ||
timeout: 1 sec, | ||
coordination: decentralized | ||
} | ||
|
||
preamble {= | ||
#include "platform.h" | ||
=} | ||
|
||
reactor Count { | ||
state count: int = 1 | ||
output out: int | ||
logical action loop | ||
|
||
reaction(startup) -> loop {= | ||
lf_schedule(loop, 0); | ||
=} | ||
|
||
reaction(loop) -> out {= | ||
if (self->count < 6) { | ||
lf_sleep(MSEC(50)); | ||
lf_set(out, self->count++); | ||
lf_schedule(loop, 0); | ||
} | ||
=} | ||
} | ||
|
||
reactor Print { | ||
input in: int | ||
state c: int = 1 | ||
state checks: int = 0 | ||
|
||
logical action loop | ||
|
||
reaction(startup) -> loop {= | ||
lf_schedule(loop, 0); | ||
=} | ||
|
||
reaction(in) {= | ||
interval_t elapsed_time = lf_time_logical_elapsed(); | ||
lf_print("At time %lld, received %d", elapsed_time, in->value); | ||
if (in->value != self->c) { | ||
lf_print_error_and_exit("Expected to receive %d.", self->c); | ||
} | ||
self->c++; | ||
=} STP(1 sec) {= | ||
lf_print_error_and_exit("STP violation. This should not happen because the STP offset is large."); | ||
=} | ||
|
||
reaction(loop) {= | ||
lf_print("checking self.checks, which is now %d...", self->checks); | ||
if (self->checks++ <= 3) { | ||
lf_schedule(loop, 0); | ||
} | ||
=} | ||
} | ||
|
||
federated reactor { | ||
c = new Count() | ||
p = new Print() | ||
c.out -> p.in after 0 | ||
} |