Skip to content

Commit ce6913f

Browse files
committed
not working
1 parent 9a95399 commit ce6913f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/benchmark/quicksort-sibling.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import {
44
InPort,
55
OutPort,
66
State,
7+
Action,
78
Reactor,
89
App,
9-
type TimeValue,
10+
TimeValue,
11+
Origin,
1012
Log
1113
} from "../core/internal";
1214

@@ -78,16 +80,15 @@ class QuickSorter extends Reactor {
7880
}
7981
);
8082

81-
this.addMutation(
83+
this.addReaction(
8284
[this.leftReadPort],
8385
[
8486
this.leftReadPort,
85-
this.rightReadPort,
8687
this.leftArr,
8788
this.rightArr,
8889
this.writable(this.parentWritePort)
8990
],
90-
function (this, leftreadport, rightreadport, leftarr, rightarr, parentWrite) {
91+
function (this, leftreadport, leftarr, rightarr, parentWrite) {
9192
const leftState = leftarr.get();
9293
const rightState = rightarr.get();
9394
const leftResult = leftreadport.get();
@@ -101,18 +102,14 @@ class QuickSorter extends Reactor {
101102
if (rightState == null) {
102103
leftarr.set(leftResult);
103104
} else {
104-
// First, detach from parent read
105-
this.disconnect(leftreadport);
106-
this.disconnect(rightreadport);
107-
this.connect(parentWrite, /* What to put here??????? */ unknown);
108105
const consolidated = [...leftResult, ...rightState];
109106
console.log(`Left completed! Setting parent to ${consolidated}`)
110107
parentWrite.set(consolidated);
111108
}
112109
}
113110
);
114111

115-
this.addMutation(
112+
this.addReaction(
116113
[this.rightReadPort],
117114
[
118115
this.rightReadPort,
@@ -151,7 +148,13 @@ class Supplier extends Reactor {
151148
super(parent, name);
152149
this.rootWritePort = new OutPort<number[]>(this);
153150
this.rootReadPort = new InPort<number[]>(this);
154-
this.writable(this.rootWritePort).set(arr);
151+
this.addReaction(
152+
[this.startup],
153+
[this.writable(this.rootWritePort)],
154+
function (this, rootwrite) {
155+
rootwrite.set(arr);
156+
}
157+
);
155158

156159
this.addReaction(
157160
[this.rootReadPort],
@@ -179,7 +182,7 @@ class Arbiter extends App {
179182
this.rootSorter = new QuickSorter(this, "rootroot");
180183
this.supplier = new Supplier(this, [5, 1, 4, 1, 1, 4, 8, 1, 0, 1, 9, 1, 9]);
181184
this._connect(this.supplier.rootWritePort, this.rootSorter.parentReadPort);
182-
// this._connect(this.rootSorter.parentWritePort, this.supplier.rootReadPort);
185+
this._connect(this.rootSorter.parentWritePort, this.supplier.rootReadPort);
183186
}
184187
}
185188

0 commit comments

Comments
 (0)