Scheduled Game Event Lifecycle

Scheduled Game Event Lifecycle A lifecycle diagram generated by Archify. 01 / Event states 02 / Cancel during callback 03 / Terminal outcomes Created · schedule_at / after · Event states 01 Created schedule_at / after Queued · wheel or overflow · Event states 02 Queued wheel or overflow Ready · deadline reached · Event states 03 Ready deadline reached Dispatching · callback runs · Event states 04 Dispatching callback runs Completed · cleanup runs once · Event states 05 Completed cleanup runs once Failed · RESULT_FAILED · Terminal outcomes Failed RESULT_FAILED Cancel Pending · callback still running · Cancel during callback Cancel Pending callback still running Cancelled · finalized · Terminal outcomes Cancelled finalized admitted deadline due batch budget COMPLETE RESCHEDULE FAILED cancel() callback returns cancel() Legend start active state waiting decision terminal success failure / exit

Timing wheel

  • • 5 levels x 64 slots, 100 ms ticks
  • • Far deadlines wait in overflow heap
  • • Due events go to the ready heap

Safe cancellation

  • • Running callbacks get CANCEL_PENDING
  • • Finalized once the callback returns
  • • Owners carry kind, id, generation

Evidence

  • • game_scheduler.h: states at line 65
  • • game_scheduler.c: outcomes 1108-1139
  • • dg_event.c: batch dispatch at 97