module ActionCable::Channel::PeriodicTimers
def active_periodic_timers
def active_periodic_timers @active_periodic_timers ||= [] end
def start_periodic_timer(callback, every:)
def start_periodic_timer(callback, every:) connection.server.event_loop.timer every do connection.worker_pool.async_exec self, connection: connection, &callback end end
def start_periodic_timers
def start_periodic_timers self.class.periodic_timers.each do |callback, options| active_periodic_timers << start_periodic_timer(callback, every: options.fetch(:every)) end end
def stop_periodic_timers
def stop_periodic_timers active_periodic_timers.each { |timer| timer.shutdown } active_periodic_timers.clear end