Sha256: bae153c23f5a10e9c6ccb445aad43c476b53b8f7d0b35af17c021c5e5a9ec5bd

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

require 'em-jack'

# WANT: namespaced under EventMachine.. would be nice :-)
# NOTE: no need for "pooling" since Beanstalk supports pipelining
module EMJack
  class Connection

    alias :ause :use
    def use(tube, &blk)
      return if @used_tube == tube

      f = Fiber.current

      # WANT: per command errbacks, would be nice, instead of one global
      # errback  = Proc.new {|r| f.resume(r) }

      on_error {|r| f.resume(r)}

      @used_tube = tube
      @conn.send(:use, tube)
      
      # WANT: Add conditional on add_deferrable to either accept two procs, or a single block
      #       .. two procs = callback, errback
      add_deferrable { |r| f.resume(r) }
      
      Fiber.yield
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-synchrony-0.1.1 lib/em-synchrony/em-jack.rb