Class: Errplane::MaxQueue

Inherits:
Queue
  • Object
show all
Defined in:
lib/errplane/max_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max = 10_000) ⇒ MaxQueue

Returns a new instance of MaxQueue.

Raises:

  • (ArgumentError)


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

#maxObject (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