Class: Errplane::MaxQueue
- Inherits:
-
Queue
- Object
- Queue
- Errplane::MaxQueue
- Defined in:
- lib/errplane/max_queue.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Instance Method Summary collapse
-
#initialize(max = 10_000) ⇒ MaxQueue
constructor
A new instance of MaxQueue.
- #push(obj) ⇒ Object
Constructor Details
#initialize(max = 10_000) ⇒ MaxQueue
Returns a new instance of MaxQueue.
7 8 9 10 11 12 |
# File 'lib/errplane/max_queue.rb', line 7 def initialize(max = 10_000) raise ArgumentError, "queue size must be positive" unless max > 0 @max = max Errplane::Worker.spawn_threads if Errplane::Worker.current_thread_count.zero? super() end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/errplane/max_queue.rb', line 5 def max @max end |
Instance Method Details
#push(obj) ⇒ Object
14 15 16 |
# File 'lib/errplane/max_queue.rb', line 14 def push(obj) super if length < @max end |