Skip to content

Commit

Permalink
not working
Browse files Browse the repository at this point in the history
  • Loading branch information
axmmisaka committed Aug 5, 2023
1 parent 302c027 commit bb1e303
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/benchmark/quicksort-sibling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import {
InPort,
OutPort,
State,
Action,
Reactor,
App,
type TimeValue,
TimeValue,
Origin,
Log
} from "../core/internal";

Expand Down Expand Up @@ -78,16 +80,15 @@ class QuickSorter extends Reactor {
}
);

this.addMutation(
this.addReaction(
[this.leftReadPort],
[
this.leftReadPort,
this.rightReadPort,
this.leftArr,
this.rightArr,
this.writable(this.parentWritePort)
],
function (this, leftreadport, rightreadport, leftarr, rightarr, parentWrite) {
function (this, leftreadport, leftarr, rightarr, parentWrite) {
const leftState = leftarr.get();
const rightState = rightarr.get();
const leftResult = leftreadport.get();
Expand All @@ -101,18 +102,14 @@ class QuickSorter extends Reactor {
if (rightState == null) {
leftarr.set(leftResult);
} else {
// First, detach from parent read
this.disconnect(leftreadport);
this.disconnect(rightreadport);
this.connect(parentWrite, /* What to put here??????? */ unknown);
const consolidated = [...leftResult, ...rightState];
console.log(`Left completed! Setting parent to ${consolidated}`)
parentWrite.set(consolidated);
}
}
);

this.addMutation(
this.addReaction(
[this.rightReadPort],
[
this.rightReadPort,
Expand Down Expand Up @@ -151,7 +148,13 @@ class Supplier extends Reactor {
super(parent, name);
this.rootWritePort = new OutPort<number[]>(this);
this.rootReadPort = new InPort<number[]>(this);
this.writable(this.rootWritePort).set(arr);
this.addReaction(
[this.startup],
[this.writable(this.rootWritePort)],
function (this, rootwrite) {
rootwrite.set(arr);
}
);

this.addReaction(
[this.rootReadPort],
Expand Down Expand Up @@ -179,7 +182,7 @@ class Arbiter extends App {
this.rootSorter = new QuickSorter(this, "rootroot");
this.supplier = new Supplier(this, [5, 1, 4, 1, 1, 4, 8, 1, 0, 1, 9, 1, 9]);
this._connect(this.supplier.rootWritePort, this.rootSorter.parentReadPort);
// this._connect(this.rootSorter.parentWritePort, this.supplier.rootReadPort);
this._connect(this.rootSorter.parentWritePort, this.supplier.rootReadPort);
}
}

Expand Down

0 comments on commit bb1e303

Please sign in to comment.