Sha256: 54d1dbb5d2a88fead3d819630410b2ff64e8a6ed773b9af2d92b46d88dca13eb

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

module Afterparty
  class Queue
    attr_accessor :options, :temp_namespace, :login_block
    include Afterparty::QueueHelpers

    def push job
      # @mutex.synchronize do
        return nil if job.nil?
        queue_name = @temp_namespace || @options[:namespace]
        AfterpartyJob.make_with_job job, queue_name
      # end
    end
    alias :<< :push
    alias :eng :push

    def pop
      # @mutex.synchronize do
        while true do
          unless (_job = AfterpartyJob.valid.first).nil?
            _job.save
            return _job
          end
          sleep(@options[:sleep])
        end
      # end
    end
  end
  
  class TestQueue < Queue
    attr_accessor :completed_jobs
    
    def initialize opts={}
      super
      @completed_jobs = []
      @exceptions = []
    end
    def handle_exception job, exception
      @exceptions << [job, exception]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
afterparty-0.1.1 lib/afterparty/queue.rb