Skip to content

Commit 0e1f736

Browse files
author
Kagamihara Nadeshiko
committed
Change CanConnect logic: remove blanket direct feedthrough ban, and always check against the global precedence graph.
1 parent 8956aaa commit 0e1f736

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
@@ -1168,34 +1168,23 @@ export abstract class Reactor extends Component {
11681168
return CanConnectResult.RT_CONNECTION_OUTSIDE_CONTAINER;
11691169
}
11701170

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

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

0 commit comments

Comments
 (0)