Class: Agent::Queue::Buffered
- Inherits:
-
Agent::Queue
- Object
- Agent::Queue
- Agent::Queue::Buffered
- Defined in:
- lib/agent/queue/buffered.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from Agent::Queue
Instance Method Summary collapse
- #buffered? ⇒ Boolean
-
#initialize(type, max = 1) ⇒ Buffered
constructor
A new instance of Buffered.
- #pop? ⇒ Boolean
- #push? ⇒ Boolean
- #unbuffered? ⇒ Boolean
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
#max ⇒ Object (readonly)
Returns the value of attribute max.
6 7 8 |
# File 'lib/agent/queue/buffered.rb', line 6 def max @max end |
#size ⇒ Object (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
14 |
# File 'lib/agent/queue/buffered.rb', line 14 def buffered?; true; end |
#pop? ⇒ Boolean
18 |
# File 'lib/agent/queue/buffered.rb', line 18 def pop?; @size > 0; end |
#push? ⇒ Boolean
17 |
# File 'lib/agent/queue/buffered.rb', line 17 def push?; @max > @size; end |
#unbuffered? ⇒ Boolean
15 |
# File 'lib/agent/queue/buffered.rb', line 15 def unbuffered?; false; end |