module Faye::Timeouts
Public Instance Methods
add_timeout(name, delay, &block)
click to toggle source
# File lib/faye/mixins/timeouts.rb, line 3 def add_timeout(name, delay, &block) Engine.ensure_reactor_running! @timeouts ||= {} return if @timeouts.has_key?(name) @timeouts[name] = EventMachine.add_timer(delay) do @timeouts.delete(name) block.call end end
remove_all_timeouts()
click to toggle source
# File lib/faye/mixins/timeouts.rb, line 21 def remove_all_timeouts @timeouts ||= {} @timeouts.keys.each { |name| remove_timeout(name) } end
remove_timeout(name)
click to toggle source
# File lib/faye/mixins/timeouts.rb, line 13 def remove_timeout(name) @timeouts ||= {} timeout = @timeouts[name] return if timeout.nil? EventMachine.cancel_timer(timeout) @timeouts.delete(name) end