Skip to content

Commit

Permalink
Strong Fast Lock Stock v0.1.62 POC: Clean Up
Browse files Browse the repository at this point in the history
  • Loading branch information
REllEK-IO committed May 8, 2024
1 parent a92eb92 commit 32d9fc9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ When in doubt simplify.
## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### **BREAKING** Strong Fast Lock Step v0.1.62
* Devised a means to ensure a lock step execution of incoming actions
* Due to each stage being ran once regardless of their selector being changed, some plans may receive the wrong value if not determining if that stage has been ran for the first time. See priority.test.ts for details.
* Due to each stage being ran once regardless of their selector being changed, some plans may receive the wrong value if not determining if that stage has been ran for the first time. See priority.test.ts for the example: if (changes.length > 0) {//}
* This also impacted the *axiumWaitForOpenThenIterate* helper function, but now works as intended via no longer checking for the latest lastStrategy change.
### Strong Fast Time v0.1.61
* Created the new *axiumTimeOut* helper function
Expand Down
4 changes: 2 additions & 2 deletions src/concepts/axium/axium.concept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export type AxiumState = {
removeConceptQue: Concept[],
badPlans: Plan[];
badActions: Action[];
timer: NodeJS.Timer[];
tailTimer: NodeJS.Timer[];
timer: NodeJS.Timeout[];
tailTimer: NodeJS.Timeout[];
timerLedger: Map<number, [(() => Action)[], number]>
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/axium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function createAxium(
if (_axiumState.tailTimer.length > 0) {
const timer = _axiumState.tailTimer.shift();
if (timer) {
clearTimeout(timer as NodeJS.Timeout);
clearTimeout(timer);
}
}
const modeIndex = _axiumState.modeIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/model/stagePlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type Plan = {
export type Stage = (
concepts: Concepts,
dispatch: (action: Action, options: dispatchOptions, ) => void,
changes?: KeyedSelector[]
changes: KeyedSelector[]
) => void;

export type Staging = {
Expand Down
2 changes: 1 addition & 1 deletion src/model/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const axiumTimeOut = (concepts: Concepts, func: () => Action, timeOut: nu
// If timer exists, first index of timerList would exist
const timerList = Object.keys(ledger).map(t => Number(t)).sort((a, b) => a - b);
if (timerList[0] > timed) {
clearTimeout(timer as NodeJS.Timeout);
clearTimeout(timer);
axiumState.timer.shift();
const slot = axiumState.timerLedger.get(timed);
if (slot) {
Expand Down
14 changes: 6 additions & 8 deletions src/test/priority/priority.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('Priority Test', (done) => {
concluded++;
}
};
const firstRun = [true, true, true];

const priorityTest = createAxium('Priority Test', [
createExperimentPriorityConcept()
], true, true, true);
Expand All @@ -47,17 +47,15 @@ test('Priority Test', (done) => {
});
}
}, {priority});
const thirdStage = (name: string, expected: number, priority: number, pos: number) => createStage((concepts, dispatch) => {
const thirdStage = (name: string, expected: number, priority: number) => createStage((concepts, dispatch, changes) => {
const priorityState = select.state<ExperimentPriorityState>(concepts, experimentName);
if (priorityState && !firstRun[pos]) {
if (priorityState && changes.length > 0) {
// expect(order).toBe(expectedOrder);
console.log(`${name} Incoming Value: ${priorityState.value}, expecting: ${expected}`);
// expect(priorityState.value).toBe(expected);
dispatch(axiumKick(), {
iterateStage: true
});
} else {
firstRun[pos] = false;
}
}, {selectors: [experimentPriorityValueSelector], priority});
const concludePlan = (name: string, func: () => StagePlanner) => createStage(() => {
Expand All @@ -72,7 +70,7 @@ test('Priority Test', (done) => {
'Low Priority Plan', [
firstStage(LOW, LOW_PRIORITY),
secondStage(LOW, 1, LOW_PRIORITY),
thirdStage(LOW, 111, LOW_PRIORITY, 0),
thirdStage(LOW, 111, LOW_PRIORITY),
concludePlan(LOW, () => low),
]);
const HIGH = 'High';
Expand All @@ -81,7 +79,7 @@ test('Priority Test', (done) => {
'High Priority Plan', [
firstStage(HIGH, HIGH_PRIORITY),
secondStage(HIGH, 100, HIGH_PRIORITY),
thirdStage(HIGH, 100, HIGH_PRIORITY, 1),
thirdStage(HIGH, 100, HIGH_PRIORITY),
concludePlan(HIGH, () => high),
]);
const MID = 'Mid';
Expand All @@ -90,7 +88,7 @@ test('Priority Test', (done) => {
'Mid Priority Plan', [
firstStage(MID, MID_PRIORITY),
secondStage(MID, 10, MID_PRIORITY),
thirdStage(MID, 110, MID_PRIORITY, 2),
thirdStage(MID, 110, MID_PRIORITY),
concludePlan(MID, () => mid),
]);
setTimeout(() => {
Expand Down

0 comments on commit 32d9fc9

Please sign in to comment.