class Puma::Reactor
def calculate_sleep
would take for the first element to time out.
Otherwise a sleep value is set that is the same as the amount of time it
comes first in the array. When there are no timeouts the default timeout is used.
The values kept in `@timeouts` are sorted so that the first timeout
sleep for in the main reactor loop when no sockets are being written to.
The `calculate_sleep` sets the value that the `NIO::Selector#select` will
def calculate_sleep if @timeouts.empty? @sleep_for = DefaultSleepFor else diff = @timeouts.first.value.timeout_at.to_f - Time.now.to_f if diff < 0.0 @sleep_for = 0 else @sleep_for = diff end end end