Class: Agent::Queue::Buffered

Inherits:
Agent::Queue show all
Defined in:
lib/agent/queue/buffered.rb

Instance Attribute Summary collapse

Attributes inherited from Agent::Queue

#operations, #type

Instance Method Summary collapse

Methods inherited from Agent::Queue

#close, #closed?, #open?, #pop, #push, #remove_operations

Constructor Details

#initialize(type, max = 1) ⇒ Buffered

Returns a new instance of Buffered.



8
9
10
11
12
# File 'lib/agent/queue/buffered.rb', line 8

def initialize(type, max=1)
  raise Errors::InvalidQueueSize, "queue size must be at least 1" unless max >= 1
  super(type)
  @max = max
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



6
7
8
# File 'lib/agent/queue/buffered.rb', line 6

def max
  @max
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/agent/queue/buffered.rb', line 6

def size
  @size
end

Instance Method Details

#buffered?Boolean

Returns:

  • (Boolean)


14
# File 'lib/agent/queue/buffered.rb', line 14

def buffered?;   true; end

#pop?Boolean

Returns:

  • (Boolean)


18
# File 'lib/agent/queue/buffered.rb', line 18

def pop?;  @size > 0;    end

#push?Boolean

Returns:

  • (Boolean)


17
# File 'lib/agent/queue/buffered.rb', line 17

def push?; @max > @size; end

#unbuffered?Boolean

Returns:

  • (Boolean)


15
# File 'lib/agent/queue/buffered.rb', line 15

def unbuffered?; false;  end