1
1
import {
2
- type WritablePort ,
3
- Parameter ,
4
2
InPort ,
5
3
OutPort ,
6
4
State ,
7
- Action ,
8
5
Reactor ,
9
6
App ,
10
- TimeValue ,
11
- Origin ,
12
- Log ,
13
- PrecedenceGraph
7
+ type TimeValue ,
8
+ Log
14
9
} from "../core/internal" ;
15
10
16
11
// 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 {
46
41
leftReactor : Reactor | undefined ;
47
42
rightReactor : Reactor | undefined ;
48
43
49
- constructor ( parent : Reactor , name = "root" ) {
50
- super ( parent , name ) ;
44
+ constructor ( parent : Reactor ) {
45
+ super ( parent ) ;
51
46
this . parentReadPort = new InPort < number [ ] > ( this ) ;
52
47
this . parentWritePort = new OutPort < number [ ] > ( this ) ;
53
48
this . leftWritePort = new OutPort < number [ ] > ( this ) ;
@@ -82,10 +77,8 @@ class QuickSorter extends Reactor {
82
77
numFragments
83
78
) {
84
79
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 ) ;
89
82
90
83
const fullarr = parentReadPort . get ( ) ;
91
84
if ( fullarr == null ) {
@@ -109,14 +102,8 @@ class QuickSorter extends Reactor {
109
102
) ;
110
103
111
104
// 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 ) ;
120
107
121
108
// Connect ports accoringly
122
109
this . connect ( leftWritePort , leftReactor . parentReadPort ) ;
@@ -197,7 +184,7 @@ class Supplier extends Reactor {
197
184
rootReadPort : InPort < number [ ] > ;
198
185
199
186
constructor ( parent : Reactor , arr : number [ ] , name = "Innocent Supplier" ) {
200
- super ( parent , name ) ;
187
+ super ( parent ) ;
201
188
this . rootWritePort = new OutPort < number [ ] > ( this ) ;
202
189
this . rootReadPort = new InPort < number [ ] > ( this ) ;
203
190
this . addReaction (
@@ -230,8 +217,8 @@ class Arbiter extends App {
230
217
success ?: ( ) => void ,
231
218
fail ?: ( ) => void
232
219
) {
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 ) ;
235
222
this . supplier = new Supplier ( this , arr ) ;
236
223
this . _connect ( this . supplier . rootWritePort , this . rootSorter . parentReadPort ) ;
237
224
this . _connect ( this . rootSorter . parentWritePort , this . supplier . rootReadPort ) ;
0 commit comments