123456789_123456789_123456789_123456789_123456789_

Module: Puma::QueueClose

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/puma/queue_close.rb

Overview

Queue#close was added in Ruby 2.3. Add a simple implementation for earlier Ruby versions.

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#closed?Boolean (readonly)

[ GitHub ]

  
# File 'lib/puma/queue_close.rb', line 12

def closed?
  @closed ||= false
end

Instance Method Details

#<<(object)

Alias for #push.

[ GitHub ]

  
# File 'lib/puma/queue_close.rb', line 19

alias << push

#close

[ GitHub ]

  
# File 'lib/puma/queue_close.rb', line 8

def close
  num_waiting.times {push nil}
  @closed = true
end

#pop(non_block = false)

[ GitHub ]

  
# File 'lib/puma/queue_close.rb', line 20

def pop(non_block=false)
  return nil if !non_block && closed? && empty?
  super
end

#push(object) Also known as: #<<

Raises:

[ GitHub ]

  
# File 'lib/puma/queue_close.rb', line 15

def push(object)
  raise ClosedQueueError if closed?
  super
end