def expire status, maxage, verbose = false
# FIXME: clean both @jobs and @queue
      # Init
      return if status.nil? || maxage <= 0

      # Compute oldest limit
      time_limit = Time.now - maxage.to_i
      log_info "expire limit [#{time_limit}] status [#{status}]" if verbose

      @mutex.synchronize do
        # Delete jobs from the queue when they match status and age limits
        @jobs.delete_if do |job|
          # log_debug "testing job [#{job.id}] updated_at [#{job.updated_at}]"

          # Skip if wrong status, updated_at invalid, or updated since time_limit
          next unless job.status == status
          next if job.updated_at.nil?
          next if job.updated_at >= time_limit

          # Ok, we have to clean it up ..
          log_info "expire [#{status}]: job [#{job.id}] updated_at [#{job.updated_at}]"

          # From any queues, remove it
          @queues.each do |pool, jobs|
            log_debug "#{LOG_INDENT}unqueued from [#{pool}]" if jobs.delete(job)
          end

          # Remember we have to delete the original job !
          true
        end
      end

    end
def expire status, maxage, verbose = false
# FIXME: clean both @jobs and @queue
      # Init
      return if status.nil? || maxage <= 0

      # Compute oldest limit
      time_limit = Time.now - maxage.to_i
      log_info "expire limit [#{time_limit}] status [#{status}]" if verbose

      @mutex.synchronize do
        # Delete jobs from the queue when they match status and age limits
        @jobs.delete_if do |job|
          # log_debug "testing job [#{job.id}] updated_at [#{job.updated_at}]"

          # Skip if wrong status, updated_at invalid, or updated since time_limit
          next unless job.status == status
          next if job.updated_at.nil?
          next if job.updated_at >= time_limit

          # Ok, we have to clean it up ..
          log_info "expire [#{status}]: job [#{job.id}] updated_at [#{job.updated_at}]"

          # From any queues, remove it
          @queues.each do |pool, jobs|
            log_debug "#{LOG_INDENT}unqueued from [#{pool}]" if jobs.delete(job)
          end

          # Remember we have to delete the original job !
          true
        end
      end

    end
Jobs cleanup