Skip to content

Schedulers

Overview

QfStudio.Godette.ReactiveUI provides three schedulers that bridge Godot's frame loop to the Rx scheduling model:

SchedulerAliasSourcePurpose
GodotMainThreadSchedulerRxSchedulers.MainThreadSchedulerSynchronizationContextMain thread callbacks
GodotSchedulers.ProcessFrameScheduler_ProcessPer-frame scheduling
GodotSchedulers.PhysicsFrameScheduler_PhysicsProcessPhysics frame scheduling

Initialization in Autoload

Create the two frame schedulers as fields and pass them to WithGodot in RxAppBootstrapper -- it creates the main-thread scheduler from SynchronizationContext.Current and exposes all three schedulers through GodotSchedulers:

csharp
private readonly GodotFrameScheduler _processFrameScheduler = new();
private readonly GodotFrameScheduler _physicsFrameScheduler = new();

RxAppBuilder.CreateReactiveUIBuilder()
    .WithGodot(_processFrameScheduler, _physicsFrameScheduler)
    // .WithGodotConverters()      // optional
    // .WithGodotViewLocator(...)  // optional
    .BuildApp();

RxAppBuilder.BuildApp() mirrors the scheduler registered via .WithMainThreadScheduler(...) (inside WithGodot) to RxSchedulers.MainThreadScheduler, so ObserveOn(RxSchedulers.MainThreadScheduler) resolves to the same GodotMainThreadScheduler.

Frame Driving

csharp
public override void _Process(double delta)
{
    _processFrameScheduler.NotifyProcess(delta);
}

public override void _PhysicsProcess(double delta)
{
    _physicsFrameScheduler.NotifyProcess(delta);
}

Calling NotifyProcess each frame drives the frame scheduler to execute queued operations. GodotSchedulers is the Godot-side alias for the same instances, used by frame operators and other Godot-specific APIs.