Sha256: d32cad2419d1913d70cdcb28116842973feba65f4f60d94634a05c6ffa2fb28d

Contents?: true

Size: 502 Bytes

Versions: 18

Compression:

Stored size: 502 Bytes

Contents

module Faye
  module Timeouts
    def add_timeout(name, delay, &block)
      Faye.ensure_reactor_running!
      @timeouts ||= {}
      return if @timeouts.has_key?(name)
      @timeouts[name] = EventMachine.add_timer(delay) do
        @timeouts.delete(name)
        block.call
      end
    end
    
    def remove_timeout(name)
      @timeouts ||= {}
      timeout = @timeouts[name]
      return if timeout.nil?
      EventMachine.cancel_timer(timeout)
      @timeouts.delete(name)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
faye-0.7.2 lib/faye/mixins/timeouts.rb
faye-0.6.8 lib/faye/mixins/timeouts.rb
faye-0.7.1 lib/faye/mixins/timeouts.rb
faye-0.7.0 lib/faye/mixins/timeouts.rb
faye-0.6.7 lib/faye/mixins/timeouts.rb
faye-0.6.6 lib/faye/mixins/timeouts.rb
faye-0.6.5 lib/faye/mixins/timeouts.rb
faye-0.6.4 lib/faye/mixins/timeouts.rb
faye-0.6.3 lib/faye/mixins/timeouts.rb
faye-0.6.2 lib/faye/mixins/timeouts.rb
faye-0.6.1 lib/faye/mixins/timeouts.rb
faye-0.6.0 lib/faye/mixins/timeouts.rb
faye-0.5.5 lib/faye/mixins/timeouts.rb
faye-0.5.4 lib/faye/mixins/timeouts.rb
faye-0.5.3 lib/faye/mixins/timeouts.rb
faye-0.5.2 lib/faye/mixins/timeouts.rb
faye-0.5.1 lib/faye/mixins/timeouts.rb
faye-0.5.0 lib/faye/mixins/timeouts.rb