11import {
2- type WritablePort ,
3- Parameter ,
42 InPort ,
53 OutPort ,
64 State ,
7- Action ,
85 Reactor ,
96 App ,
10- TimeValue ,
11- Origin ,
12- Log ,
13- PrecedenceGraph
7+ type TimeValue ,
8+ Log
149} from "../core/internal" ;
1510
1611// This is the thrshold for the quicksort algorithm, feeding sorters below this number will use Array.prototype.sort()
@@ -46,8 +41,8 @@ class QuickSorter extends Reactor {
4641 leftReactor : Reactor | undefined ;
4742 rightReactor : Reactor | undefined ;
4843
49- constructor ( parent : Reactor , name = "root" ) {
50- super ( parent , name ) ;
44+ constructor ( parent : Reactor ) {
45+ super ( parent ) ;
5146 this . parentReadPort = new InPort < number [ ] > ( this ) ;
5247 this . parentWritePort = new OutPort < number [ ] > ( this ) ;
5348 this . leftWritePort = new OutPort < number [ ] > ( this ) ;
@@ -82,10 +77,8 @@ class QuickSorter extends Reactor {
8277 numFragments
8378 ) {
8479 const hierarchyImplementation = (
85- useHierarchy
86- ? this . getReactor ( ) . _uncheckedAddChild
87- : this . getReactor ( ) . _uncheckedAddSibling
88- ) . bind ( this . getReactor ( ) ) ;
80+ useHierarchy ? this . addChild : this . addSibling
81+ ) . bind ( this ) ;
8982
9083 const fullarr = parentReadPort . get ( ) ;
9184 if ( fullarr == null ) {
@@ -109,14 +102,8 @@ class QuickSorter extends Reactor {
109102 ) ;
110103
111104 // First, create 2 new reactors
112- const leftReactor = hierarchyImplementation (
113- QuickSorter ,
114- `${ this . getReactor ( ) . _name } /l`
115- ) ;
116- const rightReactor = hierarchyImplementation (
117- QuickSorter ,
118- `${ this . getReactor ( ) . _name } /r`
119- ) ;
105+ const leftReactor = hierarchyImplementation ( QuickSorter ) ;
106+ const rightReactor = hierarchyImplementation ( QuickSorter ) ;
120107
121108 // Connect ports accoringly
122109 this . connect ( leftWritePort , leftReactor . parentReadPort ) ;
@@ -197,7 +184,7 @@ class Supplier extends Reactor {
197184 rootReadPort : InPort < number [ ] > ;
198185
199186 constructor ( parent : Reactor , arr : number [ ] , name = "Innocent Supplier" ) {
200- super ( parent , name ) ;
187+ super ( parent ) ;
201188 this . rootWritePort = new OutPort < number [ ] > ( this ) ;
202189 this . rootReadPort = new InPort < number [ ] > ( this ) ;
203190 this . addReaction (
@@ -230,8 +217,8 @@ class Arbiter extends App {
230217 success ?: ( ) => void ,
231218 fail ?: ( ) => void
232219 ) {
233- super ( timeout , keepAlive , fast , success , fail , name ) ;
234- this . rootSorter = new QuickSorter ( this , "root" ) ;
220+ super ( timeout , keepAlive , fast , success , fail ) ;
221+ this . rootSorter = new QuickSorter ( this ) ;
235222 this . supplier = new Supplier ( this , arr ) ;
236223 this . _connect ( this . supplier . rootWritePort , this . rootSorter . parentReadPort ) ;
237224 this . _connect ( this . rootSorter . parentWritePort , this . supplier . rootReadPort ) ;
0 commit comments