Class: DroppingSizedQueue
- Inherits:
-
SizedQueue
- Object
- SizedQueue
- DroppingSizedQueue
- Defined in:
- lib/lpxc.rb
Overview
Like SizedQueue, but drops instead of blocking. Pass one of these in as :request_queue if you would prefer loss to slowing down in cases of back-pressure.
Instance Method Summary collapse
-
#push(obj) ⇒ Object
Returns true/false depending on whether the queue is full or not.
Instance Method Details
#push(obj) ⇒ Object
Returns true/false depending on whether the queue is full or not
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lpxc.rb', line 36 def push(obj) @mutex.synchronize do return false unless @que.length < @max @que.push obj begin t = @waiting.shift t.wakeup if t rescue ThreadError retry end return true end end |