Sha256: f0a9da3ae104c27a93dca9f07d61bfe04011d0fbeffd428bbb946b7c0f1bfc69

Contents?: true

Size: 500 Bytes

Versions: 4

Compression:

Stored size: 500 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
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
faye-0.8.11 lib/faye/mixins/timeouts.rb
faye-1.0.0 lib/faye/mixins/timeouts.rb
face-faye-0.8.9 lib/faye/mixins/timeouts.rb
faye-0.8.9 lib/faye/mixins/timeouts.rb