Skip to content

Commit 56bef5b

Browse files
authored
Handle unconnected inputs and add test (#204)
* Handle unconnected inputs and add test * Format
1 parent 7f5fd0e commit 56bef5b

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

src/schedulers/dynamic/scheduler.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ static lf_ret_t Scheduler_federated_acquire_tag(Scheduler *untyped_self, tag_t n
6060
instant_t additional_sleep = 0;
6161
for (size_t i = 0; i < env->net_bundles_size; i++) {
6262
FederatedConnectionBundle *bundle = env->net_bundles[i];
63+
64+
if (!bundle->net_channel->is_connected(bundle->net_channel)) {
65+
continue;
66+
}
67+
6368
for (size_t j = 0; j < bundle->inputs_size; j++) {
6469
FederatedInputConnection *input = bundle->inputs[j];
6570
// Find the max safe-to-assume-absent value and go to sleep waiting for this.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
target uC {
2+
platform: Native,
3+
timeout: 1sec
4+
}
5+
6+
7+
reactor Dst {
8+
input in: int
9+
state check: bool = false
10+
reaction(startup) {=
11+
printf("Hello from Dst!\n");
12+
self->check = true;
13+
=}
14+
reaction(in) {=
15+
printf("Received %d from Src\n", in->value);
16+
validate(in->value == 42);
17+
env->request_shutdown(env);
18+
=}
19+
20+
reaction(shutdown) {=
21+
validate(self->check);
22+
=}
23+
}
24+
25+
federated reactor {
26+
r2 = new Dst()
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
target uC {
2+
platform: Native,
3+
timeout: 1sec,
4+
logging: Debug
5+
}
6+
7+
reactor Src(id: int = 0) {
8+
output out: int
9+
reaction(startup) -> out{=
10+
printf("Hello from Src!\n");
11+
lf_set(out, self->id);
12+
=}
13+
}
14+
15+
reactor Dst {
16+
input in: int
17+
input in2: int
18+
state check: bool = false
19+
20+
reaction(in) {=
21+
printf("Received %d from Src\n", in->value);
22+
validate(in->value == 42);
23+
self->check = true;
24+
env->request_shutdown(env);
25+
=}
26+
27+
reaction(startup) {=
28+
printf("Hello from Dst!\n");
29+
=}
30+
31+
32+
reaction(shutdown) {=
33+
validate(self->check);
34+
=}
35+
36+
}
37+
38+
federated reactor {
39+
r1 = new Src(id=42)
40+
r2 = new Dst()
41+
r1.out -> r2.in
42+
}

0 commit comments

Comments
 (0)