That’s a great resource. I’m familiar with Go’s context module, which implements the same thing.
This might be more relevant input for RFC 0014, though?
main ← general-timeouts
opened 10:34PM - 01 Aug 25 UTC
Synchronization primitives, such as mutexes, condition variables, pools, or even… t channels, could take advantage of a general timeout mechanism.
Crystal has a mechanism in the event loop to suspend the execution of a fiber for a set amount of time (`#sleep`). It also has a couple mechanisms to add timeouts: one associated to IO operations, and another tailored to `Channel` and `select` to support the timeout branch of select actions.
Adding timeouts to all the synchronization primitives in the stdlib, and possibly to custom ones in shards and applications, shouldn't be much harder than calling `#sleep`, or need to hack into the private `Fiber#timeout_event`.
**Preview:** https://github.com/crystal-lang/rfcs/blob/general-timeouts/text/0014-cancelable-timers.md
EDIT: I see you posted there as well already