Why I reimplemented Trio in a game engine
summary
Reimplemented Trio-style structured concurrency inside the Wasabi2D game engine and actually ships games using it, claiming it simplifies game logic by making lifetimes explicit and cleanup automatic. Uses async functions, nurseries and cancellation scopes plus event objects to spawn enemy waves, bullets and iris doors; cancellation throws into every task and collapses a task tree so explosions and cleanup run reliably. Scheduler favors earliest-created tasks and time is frame-discrete rather than continuous; the Pi Week infinite-waves demo works and reduced state-bug headaches.
AI-written summary · about
chapters (18)
- 0:00A Standard PyGame Tutorial
- 0:24Hard-coded game loop
- 0:55Scenegraph
- 1:51Taking the concurrent view
- 2:45Update functions do busy work
- 3:10Coroutines to the rescue!
- 4:41Unity Game Engine
- 5:38Scratch has implicit coroutines
- 6:54Subtasks are launched through nurseries
- 8:55Asyncio Task Group arriving in 3.11
- 10:43Enemies that come in waves
- 11:28Each ship is a bundle of tasks
- 12:11Awaiting input
- 14:26Outer cancellation implies inner cancellation
- 18:24Event Objects
- 19:05Synchronisation using events
- 20:04Event loops
- 22:18Discrete vs continuous time
related talks
32mTrio: Async concurrency for mere mortals
47mTaking Asynchronous Python to the Next Level Using Trio
37mTaking Asynchronous Python to the Next Level Using Trio
15mEvent-Driven asyncio: A Case Study of Trio's API
01h 00mCoroutine Concurrency in Python 3 with asyncio
28mMaking Games
41mSimpl framework, big impact!
22mA Scientific Game Engine in the Cloud
