Open Soroosh129 opened 2 years ago
Maybe this is another place where annotations could save the day. Suppose we add an annotation that is an assertion that the reaction only reads or writes to one of the bank members.
Maybe this is another place where annotations could save the day. Suppose we add an annotation that is an assertion that the reaction only reads or writes to one of the bank members.
That is an interesting idea. I think this would solve the problem.
Still, we could also conceivably make each bank member addressable in reactions' signature (and potentially in connections).
because there is no way to use individual bank members as triggers for reactions.
There actually is a way:
reactor NetworkReceive {
output o: Type
reaction (...) -> o {=
/* ... */
=}
}
reactor NetworkSend {
input i: Type
reaction (i) -> ... {=
/* ... */
=}
}
main reactor (width: size_t(10)) {
c = new[width] Contained()
s = new[width] NetworkSend()
r = new[width] NetworkReceive()
r.o -> c.in;
c.out -> s.i;
}
By using reactors with a single reaction we can put them in a bank and thus have different reaction instances for the different instances of Contained (or PassThrough). Or is there some additional constraint that I am missing?
This is a great idea!
A cycle is incorrectly detected in the following program:
The cycle goes away if the
federated
reactor is changed tomain
.The reason behind this is a bit complicated to explain. In short, the generated network reactions (see #608) for the input and output ports of each of the 10
PassThrough
federates depend on all the otherPassThrough
federates, because there is no way to use individual bank members as triggers for reactions.For example, the following is not possible:
Instead, all generated reactions will look like
reaction(c.out) -> c.in {==}
creating dependencies that result in a cycle.