Skip to content

Commit

Permalink
Merge pull request #86 from Phuire-Research/UI
Browse files Browse the repository at this point in the history
UI
  • Loading branch information
REllEK-IO committed Oct 12, 2023
2 parents 59de624 + 77a89e0 commit e47ef54
Show file tree
Hide file tree
Showing 3 changed files with 39 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.29",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
39 changes: 33 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 Expand Up @@ -230,6 +251,12 @@ export class UnifiedSubject extends Subject<Concept[]> {
if (options?.setStage) {
plan.stage = options.setStage;
}
if (options?.iterateStage || (options?.setStage && options.setStage !== plan.stage)) {
stageDelimiter.prevActions = [];
stageDelimiter.unionExpiration = [];
stageDelimiter.runOnceMap = new Map();
this.stageDelimiters.set(key, stageDelimiter);
}
// Horrifying
// Keep in place, this prevents branch prediction from creating ghost actions if there is an action overflow.
if (plan.stageFailed === -1) {
Expand Down

0 comments on commit e47ef54

Please sign in to comment.