Coordinators and managers
SchedulerFlowController
The entry point for the Scheduler domain. It inherits from FlowController, so it receives Scheduler commands from the CommandBus.
- Forwards each command to
SchedulerManager.ProcessCommand. - Registers the scheduler manager with the update system during
Init, so it is ticked each frame. - Subscribes to the Data domain on the
EventBusand forwards those events toSchedulerManager.ProcessEvent.
Its dependencies are FlowController (base class and command registration), ServiceLocator (for the EventBus), and UpdateCommandFactory (for update registration).
SchedulerManager
An abstract class that holds the job dictionary and does the scheduling work.
- Processes commands: schedules jobs, pauses, resumes, and cancels.
- Ticks through
IUpdateable.OnUpdate. Each tick finds due jobs and runs them. - Requires a project-specific subclass that implements
ProcessEvent.
It uses SchedulerService for validation, due checks, and completion, SchedulerUtility for ID assignment and job creation, and SchedulerEventFactory for pause and resume notifications. It reads time from UnityEngine.Time and the paused speed from ApplicationConstants.
SchedulerService
A static class with three operations: validate a config, find due jobs and tick their timers, and decide what happens after a job completes. It works on dictionaries and lists passed to it and holds no state of its own.
SchedulerUtility
A small static helper that wraps the ID counter, job creation, and the timer and due checks on a job record. It exists so that SchedulerService and SchedulerManager do not touch the counter or the job record directly.
Factories
SchedulerCommandFactory
Static methods that build Scheduler commands and send them with BusUtility.Send. Callers use these methods instead of building commands by hand.
- Schedule methods (single entity, dual entity, attribute param, callback) send a Schedule command carrying the job.
PauseScheduler,ResumeScheduler, andCancelScheduledJobssend their matching verbs.
It depends on Command.Create for the message, SchedulerKeys for params, and BusUtility for delivery.
SchedulerEventFactory
Static methods that raise Paused and Resumed events on the Scheduler domain through BusUtility.Raise. It depends on Event for the message and on SchedulerEventVerb for the verb values.
Job data and interfaces
IScheduledJob
The contract every job payload implements. It supplies JobMetaData for timing, Execute to run the job, and an optional SetJobID that receives the job's ID before each run.
CallbackJob
A ready-made IScheduledJob that wraps an Action. Its Execute runs the action and returns true. It is the simplest way to schedule a delegate.
SchedulerConstants.Job
The scheduler's internal record for a scheduled job. It holds the ID, the countdown delay, the interval, the remaining repeat count, the Config, and the Params the job was scheduled with. The manager updates its timing state, and nothing else changes it.
Config
A struct with timing values (Delay, Interval, RepeatCount) and optional Event and ICommand fields. The Event and Command fields are carried for the job's own use. The scheduler does not read them.
JobMetadata
A struct that pairs a Config with a Tag string. The Tag is not read by the scheduler.
Keys, verbs, and enums
SchedulerKeys: typedParamKeyinstances for the job payload and the subject.SchedulerKeyNames: the string names behind those keys.SchedulerCommandVerbs: verbs for commands sent to the scheduler (Schedule, Pause, Resume, Cancel).SchedulerEventVerb: verbs for events raised by the scheduler (Paused, Resumed). Declared in the Contracts namespace.SchedulerSubject: the subject of a Scheduler message. Currently onlyJob.
Dependency interactions
- FlowController (base class): the scheduler's flow controller inherits its command registration.
HandleCommandis the override point. - CommandBus through BusUtility: delivers scheduler commands to the flow controller, and carries the update registration sent by
UpdateCommandFactory. - EventBus through BusUtility and ServiceLocator: carries scheduler notifications out and Data-domain events in.
- UpdateCommandFactory and the update system: register
SchedulerManageras anIUpdateable. ItsOnUpdateruns each frame. - Params and ParamKey: carry the job and subject in each command.
Params.Getthrows if a key is missing, so commands must include the keys the manager reads. - Domain:
Domain.Schedulerroutes commands and events to this system.Domain.Datais the source of events the controller listens to. - ApplicationConstants: supplies the paused speed the manager checks before ticking.