Module: Puma::QueueClose
- Included in:
- Puma
- 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 Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #pop(non_block = false) ⇒ Object
- #push(object) ⇒ Object (also: #<<)
Instance Method Details
#close ⇒ Object
8 9 10 11 |
# File 'lib/puma/queue_close.rb', line 8 def close num_waiting.times {push nil} @closed = true end |
#closed? ⇒ Boolean
12 13 14 |
# File 'lib/puma/queue_close.rb', line 12 def closed? @closed ||= false end |
#pop(non_block = false) ⇒ Object
20 21 22 23 |
# File 'lib/puma/queue_close.rb', line 20 def pop(non_block=false) return nil if !non_block && closed? && empty? super end |
#push(object) ⇒ Object Also known as: <<
15 16 17 18 |
# File 'lib/puma/queue_close.rb', line 15 def push(object) raise ClosedQueueError if closed? super end |