Build a cooperative Ruby fiber scheduler
8 steps · about 2 h 32 min · Intermediate
- Learn the Fiber lifecycle (reference, Ruby documentation, 20 min)
The core class defines creation, transfer, resumption and the states a scheduler must respect.
- Map the scheduler interface (reference, Ruby documentation, 24 min)
The interface lists the hooks Ruby uses to delegate blocking operations to a scheduler.
- Represent nonblocking I/O work (reference, Ruby documentation, 20 min)
IO methods and readiness behaviour provide the concrete operations the scheduler coordinates.
- Manage buffers at nonblocking boundaries (reference, Ruby documentation, 14 min)
IO::Buffer exposes the storage and readiness concerns used by modern scheduler-aware I/O.
- Handle waits without freezing all work (reference, Ruby documentation, 16 min)
Process waits are another blocking boundary a complete scheduler must understand or reject explicitly.
- Contrast cooperative fibers with threads (reference, Ruby documentation, 18 min)
Threads have different scheduling, synchronisation and failure characteristics that should not be attributed to fibers.
- Separate scheduling from parallel isolation (reference, Ruby documentation, 18 min)
Ractors solve an isolation and parallelism problem rather than acting as drop-in fiber tasks.
- Test ordering, failure and cancellation (reference, Ruby documentation, 22 min)
Explicit exception handling helps tests prove progress, failure propagation, cancelled waits and cleanup at shutdown.