Zero-allocation async/await for the Panda3D C# bindings.
Heavily inspired by UniTask.
Provides:
PandaTask/PandaTask<T>— a struct task type analogous to UniTask, with a pooled state-machine runner (no allocation for sync-completed awaits or per-frame yields).PandaTaskCompletionSource— safe to complete from any thread; backed by a nativeAsyncFutureso cross-thread signalling is handled by the existing atomic state machine.- Chain-aware continuations — after
await, control resumes on the sameAsyncTaskChainit started on.ConfigureAwait(false)opts out. SynchronizationContextbridge —await httpClient.GetAsync(…)inside a coroutine automatically resumes on the originating chain, so scene-graph mutation after a network call is thread-safe.- Interop with
System.Threading.Tasks.TaskviaAsTask()/PandaTask.FromTask().
Panda3D.Interop1.11.*
Nothing else. All native support (the ManagedAsyncTask class and
the AsyncFuture C# extension methods) ships inside the existing
Panda3D.Runtime.{rid} packages — Panda3D.Async is pure managed
code.
-
samples/asteroids-async— Asteroids ported to coroutines. Side-by-side with the imperativeraw-asteroidssample, this is the minimal "look, the same game, but withawait NextFrame()andawait Delay()" comparison. -
samples/mission-control— interactive solar-system tech demo. Textured planets orbit a sun on per-planet coroutines while a HUD reflects what the engine is doing. Keys exercise the async features the asteroids sample doesn't:Key Demonstrates FPeriodic + on-demand HTTP fetch — await httpClient.GetStringAsync(...)resumes on the scene chain via theSynchronizationContextbridge.POne-shot HTTP ping with measured roundtrip. RCPU offload — await PandaTask.SwitchToChain("workers")runs heavy compute on worker threads, hops back to "default" before mutating planet state.GNative async asset load — loader.MakeAsyncRequest+await IAsyncFutureto splice a freshly-loaded model into the running scene.S/LSave/load orbit state via File.WriteAllTextAsync/ReadAllTextAsync—Taskawaited inside aPandaTaskcoroutine.CCooperative cancellation — replaces the in-flight CancellationTokenSource.ESCQuit. Always-on background coroutines: per-planet orbit + axial spin, slowly-orbiting camera, periodic HTTP heartbeat, and a real
Thread-backed sensor producer feeding aChannel— its startup is gated on a cross-threadPandaTaskCompletionSourcethe consumer awaits.Set
MC_AUTOQUIT=Nto auto-quit after N seconds (handy for smoke tests).