Skip to content

Commit d140fdc

Browse files
Kagamihara Nadeshikolhstrh
authored andcommitted
Change CanConnect logic: remove blanket direct feedthrough ban, and always check against the global precedence graph.
1 parent cd36e80 commit d140fdc

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

__tests__/InvalidMutations.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ class R1 extends Reactor {
3838
[this.in1],
3939
[this.in1, this.in2, this.out1, this.out2],
4040
function (this, __in1, __in2, __out1, __out2) {
41-
test("expect error on creating creating direct feed through", () => {
42-
expect(() => {
43-
this.connect(__in2.asConnectable(), __out2.asConnectable());
44-
}).toThrowError("New connection introduces direct feed through.");
45-
});
4641
test("expect error when creating connection outside container", () => {
4742
expect(() => {
4843
this.connect(__out2.asConnectable(), __in2.asConnectable());

src/core/reactor.ts

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,34 +1169,23 @@ export abstract class Reactor extends Component {
11691169
return CanConnectResult.RT_CONNECTION_OUTSIDE_CONTAINER;
11701170
}
11711171

1172-
// Take the local graph and merge in all the causality interfaces
1173-
// of contained reactors. Then:
1174-
const graph = new PrecedenceGraph<Port<unknown> | Reaction<Variable[]>>();
1175-
graph.addAll(this._dependencyGraph);
1176-
1177-
for (const r of this._getOwnReactors()) {
1178-
graph.addAll(r._getCausalityInterface());
1172+
/**
1173+
* TODO (axmmisaka): The following code is commented for multiple reasons:
1174+
* The causality interface check is not fully implemented so new checks are failing
1175+
* Second, direct feedthrough itself would not cause any problem *per se*.
1176+
* To ensure there is no cycle, the safest way is to check against the global dependency graph.
1177+
*/
1178+
1179+
let app = this as Reactor;
1180+
while (app._getContainer() !== app) {
1181+
app = app._getContainer();
11791182
}
1180-
1181-
// Add the new edge.
1183+
const graph = app._getPrecedenceGraph();
11821184
graph.addEdge(src, dst);
1183-
1184-
// 1) check for loops
1185-
const hasCycle = graph.hasCycle();
1186-
if (hasCycle) {
1185+
if (graph.hasCycle()) {
11871186
return CanConnectResult.RT_CYCLE;
11881187
}
11891188

1190-
// 2) check for direct feed through.
1191-
// FIXME: This doesn't handle while direct feed thorugh cases.
1192-
if (
1193-
src instanceof InPort &&
1194-
dst instanceof OutPort &&
1195-
dst.getContainer() === src.getContainer()
1196-
) {
1197-
return CanConnectResult.RT_DIRECT_FEED_THROUGH;
1198-
}
1199-
12001189
return CanConnectResult.SUCCESS;
12011190
}
12021191
}

0 commit comments

Comments
 (0)