Refactor EventLoop interface for sleeps & select timeouts#14980
Conversation
Sleep and registering a select action are always setting a Time::Span and don't need to deal with a nilable. The exception is IO::Evented that keeps a cache of libevent events and must be able to remove the timeout in case @read_timeout would have been set to nil before a second wait on read.
|
|
I doubt it needs it though.
EventLoop interface for sleeps & select timeouts
|
This PR actually changes the API. you have to pass 2 args to Fiber#timeout() and nil is no longer an option. I am not saying this is the wrong choice but it did break a library. Should there be a PR to add a deprecation warning or something? |
|
That method should actually be nodoc (like the related methods): there's no way to create a |
|
Yeah, this is technically a breaking change because the method was part of the public API. But I suppose it wont't be feasible to uphold this signature in a deprecated state because of the internal changes requiring a @jkthorne Could you tell a bit more about how/where this is used? Does it also cancel the timeout, and if so, how? |
A couple refactors related to select timeout and the signature of Crystal::EventLoop::Event#add that only needs to handle a nilable for libevent (because it caches events); other loop don't need that.
Extracted from #14959