From bb1e303a3ddaf6f7850dfd35df576aa6592a0d3d Mon Sep 17 00:00:00 2001 From: Kagamihara Nadeshiko Date: Sat, 5 Aug 2023 13:27:44 -0700 Subject: [PATCH] not working --- src/benchmark/quicksort-sibling.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/benchmark/quicksort-sibling.ts b/src/benchmark/quicksort-sibling.ts index 3d9a30a3b..02a81f491 100644 --- a/src/benchmark/quicksort-sibling.ts +++ b/src/benchmark/quicksort-sibling.ts @@ -4,9 +4,11 @@ import { InPort, OutPort, State, + Action, Reactor, App, - type TimeValue, + TimeValue, + Origin, Log } from "../core/internal"; @@ -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(); @@ -101,10 +102,6 @@ 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); @@ -112,7 +109,7 @@ class QuickSorter extends Reactor { } ); - this.addMutation( + this.addReaction( [this.rightReadPort], [ this.rightReadPort, @@ -151,7 +148,13 @@ class Supplier extends Reactor { super(parent, name); this.rootWritePort = new OutPort(this); this.rootReadPort = new InPort(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], @@ -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); } }