Sha256: 40ac0d0697672d9cc11daf903c0cce5706ba30e2474c33ad20180303912dd3f2

Contents?: true

Size: 504 Bytes

Versions: 11

Compression:

Stored size: 504 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

11 entries across 11 versions & 3 rubygems

Version Path
faye-0.8.8 lib/faye/mixins/timeouts.rb
faye-0.8.6 lib/faye/mixins/timeouts.rb
faye-0.8.5 lib/faye/mixins/timeouts.rb
faye-0.8.4 lib/faye/mixins/timeouts.rb
faye-0.8.3 lib/faye/mixins/timeouts.rb
faye-0.8.2 lib/faye/mixins/timeouts.rb
_bushido-faye-0.8.2 lib/faye/mixins/timeouts.rb
_bushido-faye-0.8.1 lib/faye/mixins/timeouts.rb
bushido-faye-0.8.1 lib/faye/mixins/timeouts.rb
faye-0.8.1 lib/faye/mixins/timeouts.rb
faye-0.8.0 lib/faye/mixins/timeouts.rb