Sha256: 2c9eaf22cba450258aa2e5317bb6f2f17d029ac02b17a424cac42bae2c892fff

Contents?: true

Size: 617 Bytes

Versions: 16

Compression:

Stored size: 617 Bytes

Contents

module Faye
  module Timeouts
    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

    def remove_timeout(name)
      @timeouts ||= {}
      timeout = @timeouts[name]
      return if timeout.nil?
      EventMachine.cancel_timer(timeout)
      @timeouts.delete(name)
    end

    def remove_all_timeouts
      @timeouts ||= {}
      @timeouts.keys.each { |name| remove_timeout(name) }
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
faye-1.4.0 lib/faye/mixins/timeouts.rb
faye-1.3.0 lib/faye/mixins/timeouts.rb
faye-1.2.5 lib/faye/mixins/timeouts.rb
faye-1.1.3 lib/faye/mixins/timeouts.rb
faye-1.2.4 lib/faye/mixins/timeouts.rb
faye-1.2.3 lib/faye/mixins/timeouts.rb
faye-1.2.2 lib/faye/mixins/timeouts.rb
faye-1.2.1 lib/faye/mixins/timeouts.rb
faye-1.2.0 lib/faye/mixins/timeouts.rb
faye-ouvrages-1.1.2.1 lib/faye/mixins/timeouts.rb
faye-ouvrages-1.1.2 lib/faye/mixins/timeouts.rb
faye-1.1.2 lib/faye/mixins/timeouts.rb
faye-1.1.1 lib/faye/mixins/timeouts.rb
faye-1.1.0 lib/faye/mixins/timeouts.rb
faye-huboard-1.0.5 lib/faye/mixins/timeouts.rb
faye-huboard-1.0.4 lib/faye/mixins/timeouts.rb