Skip to content

Commit

Permalink
Prevented potentially memory bloat and made note in StagePlanner md
Browse files Browse the repository at this point in the history
  • Loading branch information
REllEK-IO committed Oct 12, 2023
1 parent 09c1877 commit 547ea6b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
6 changes: 5 additions & 1 deletion StagePlanner.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ const plan = axium.stage('Stage DispatchOptions Test',
}
]);
```
To prevent action overflow, each stage is paying attention to consecutive actions of the same type. In an action overflow state, sequentially the overflow will call the same dispatch before called the next dispatch even if within the same stage.
To prevent action overflow, each stage is paying attention to consecutive actions of the same type. Noting that this can likewise be overwhelmed via a debounce set to 0. If debounce 0 is utilized, the current stage should change.

Keep in mind behind the scenes during a STRX runtime, there will be multiple strategies running concurrently. Observe the runCount specified in this example. Please look to the STRX's tests folder.

To save on potential memory bloat we are only keeping track of the most recent valid 5 actions per stage to prevent action overflow. This may change in the future pending some stage that requires a larger bandwidth of actions. Likewise the amount of actions in each stage should be limited regardless.

Lastly, in an action overflow state, sequentially the overflow will call the same dispatch before calling the next dispatch even if within the same stage. Pay attention to the example above and the final console.log() output.

## Stage Planner within your Principle
STRX is designed to be ran primarily through its loaded concepts and their associated principles. To prevent unexpected behaviors in your own principles. Please utilize the supplied KeyedSelector for axium's open property to begin the stage of your concepts.
```typescript
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phuire/strx",
"version": "0.0.27",
"version": "0.0.28",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
33 changes: 27 additions & 6 deletions src/model/stagePlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,33 @@ const handleStageDelimiter =
goodAction = false;
}
} else if (stageDelimiter) {
stageDelimiter = {
stage: plan.stage,
prevActions: [...stageDelimiter.prevActions, action.type],
unionExpiration: [...stageDelimiter.unionExpiration, action.expiration],
runOnceMap: new Map()
};
if (stageDelimiter.prevActions.length > 4) {
stageDelimiter = {
stage: plan.stage,
prevActions: [
stageDelimiter.prevActions[1],
stageDelimiter.prevActions[2],
stageDelimiter.prevActions[3],
stageDelimiter.prevActions[4],
action.type
],
unionExpiration: [
stageDelimiter.unionExpiration[1],
stageDelimiter.unionExpiration[2],
stageDelimiter.unionExpiration[3],
stageDelimiter.unionExpiration[4],
action.expiration
],
runOnceMap: new Map()
};
} else {
stageDelimiter = {
stage: plan.stage,
prevActions: [...stageDelimiter.prevActions, action.type],
unionExpiration: [...stageDelimiter.unionExpiration, action.expiration],
runOnceMap: new Map()
};
}
} else {
stageDelimiter = {
stage: plan.stage,
Expand Down

0 comments on commit 547ea6b

Please sign in to comment.