Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(process): rework #108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

fix(process): rework #108

wants to merge 5 commits into from

Conversation

siriuslatte
Copy link
Contributor

@siriuslatte siriuslatte commented May 21, 2023

Description
Proposed Changes
  • Rework to Scheduler (breaking changes, a complete rework to the API & optimizations)
  • Rework to Process (not breaking changes to existing code)
  • Ticks per second configuration individually for Processes
  • Status method, which indicates the current status of the process
Tasks
  • Rework done
  • Tests Created
  • Tests Passing
Documentation
Notes

No more details, a review on this is required.

Linked

No linked issues.

Forgot to modify the src file where the imports are done.
@siriuslatte siriuslatte self-assigned this May 21, 2023
@siriuslatte siriuslatte requested a review from RigidStudios May 21, 2023 17:21
src/index.ts Outdated
return Process.processes.get(name)!;
export function process(
name: string,
executionGroup?: RBXScriptSignal,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can execution group be the same as in the ECS? It seems weird to have the same name in two places but supporting different functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking on this as well, I was going to discuss this with Luna, if processes can be the same as Systems as in the ECS.

@siriuslatte
Copy link
Contributor Author

Docs being made for this on morning.

@siriuslatte
Copy link
Contributor Author

This worths giving it a show, current way of interacting with a process.

/**
 * Schedulers
 */
class PreHighScheduler extends Scheduler {
    constructor() {
        super();

        this.executionGroup = RunService.PreSimulation;
    }

    /** Methods of your own */
}

export const CameraScheduler = new PreHighScheduler()

CameraScheduler.schedule(process: Process); // Schedules a new process to the current scheduler.
CameraScheduler.unschedule(process: Process); // Unschedules the process within the next resumption cycle

CameraScheduler.suspend(process: Process, nOfTicks: number); // Suspends specified process.
CameraScheduler.unsuspend(process: Process); // Unsuspends process within the next resumption cycle

CameraScheduler.has(process: Process); // Checks whether the process is owned by this Scheduler.
CameraScheduler.isSuspended(process: Process); // Returns true if the process it's suspended.

CameraScheduler.stop(); // Stops all current on-going tasks.
CameraScheduler.resume(); // Resumes Scheduler.
 
/**
 * Processes
 */
class BuildingCameraProcess extends Process {
    constructor() {
        super()

        this.scheduler = CameraScheduler;
    }

    public override update(): void {
        ...moveCamera;
    }
}

// Whenever the process is needed, it shall be created.
OnInput(() => {
    const CameraProcess = new BuildingCameraProcess();

    CameraProcess.suspend(nOfTicks: number); // Suspends current process n amount of ticks.
    CameraProcess.resume(); // Resumes current process (deferred to the end of the current resumption cycle).
    CameraProcess.status(); // Returns current status of the Process (active | dead | suspended | unknown).
    CameraProcess.delete(); // Unschedules itself from its scheduler.
})

@siriuslatte siriuslatte marked this pull request as ready for review June 10, 2023 16:39
@christopher-buss christopher-buss removed their request for review May 6, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants