Sha256: 1b36cdab35cff876463f073caa06e11d9c83766ec113f0bbd3ced47327a3b648

Contents?: true

Size: 544 Bytes

Versions: 36

Compression:

Stored size: 544 Bytes

Contents

class ClosedQueueError < StandardError; end
module Puma

  # Queue#close was added in Ruby 2.3.
  # Add a simple implementation for earlier Ruby versions.
  #
  module QueueClose
    def close
      num_waiting.times {push nil}
      @closed = true
    end
    def closed?
      @closed ||= false
    end
    def push(object)
      raise ClosedQueueError if closed?
      super
    end
    alias << push
    def pop(non_block=false)
      return nil if !non_block && closed? && empty?
      super
    end
  end
  ::Queue.prepend QueueClose
end

Version data entries

36 entries across 36 versions & 4 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/puma-5.5.2/lib/puma/queue_close.rb
puma-5.5.2-java lib/puma/queue_close.rb
puma-5.5.2 lib/puma/queue_close.rb
puma-5.5.1-java lib/puma/queue_close.rb
puma-5.5.1 lib/puma/queue_close.rb
puma-5.5.0-java lib/puma/queue_close.rb
puma-5.5.0 lib/puma/queue_close.rb
piesync-puma-5.4.0.1 lib/puma/queue_close.rb
puma-5.4.0-java lib/puma/queue_close.rb
puma-5.4.0 lib/puma/queue_close.rb
puma-5.3.2-java lib/puma/queue_close.rb
puma-5.3.2 lib/puma/queue_close.rb
puma-5.3.1-java lib/puma/queue_close.rb
puma-5.3.1 lib/puma/queue_close.rb
puma-5.3.0-java lib/puma/queue_close.rb
puma-5.3.0 lib/puma/queue_close.rb