Stackful coroutine based rust async story
summary
May is a Rust library implementing stackful generators and coroutines as an alternative async model to the official futures system. The talk covers May’s design and implementation: generator/coroutine concepts, coroutine scheduling architecture, its IO subsystem, a sync preemptive subsystem, and cancellation handling, and includes a comparison with future-based async systems.
AI-written summary · about
chapters (7)
- 0:00STACKFUL COROUTINE IN RUST ANOTHER ASYNC STORY
- 6:01STACKFUL GENERATOR KEY FEATURES • detect current context type • Bend and yield with parameters
- 6:53STACKFUL COROUTINE • coroutine is a special thread (user space / light) • scheduler running on multi-thread semantic blocking is not real blocking call API without directly yield keep the same interface as std library
- 8:17DIFFERENCE WITH GENERATOR • coroutine is a special penerator • stackful coroutine can yield from any point directly to scheduler - always yield a "kernel request" when resume the scheduler send back the result init with Coroutine Local Storage
- 16:41SYNC PRIMITIVE SUB SYSTEM • yield blocker kernel request • save the suspending coroutines within primitive internal queue - scheduling the coroutines on normal scheduler with work stealing support Semphore/Mutex/RwLock/Condvar/SyncFlap/MPSC
- 17:38THE BLOCKER all sync primitives are implemented based on blocker • the blocker could return Timeout/Canceled/Ok - the blocker support running in thread context
- 19:39COROUTINE CANCELLATION • we tripper a special panic when detect cancel • the cancel panic would be caught and we have chance to mark the coroutine as cancelled • can only detect cancel when switch from/to








