Class: LogStash::Util::WrappedSynchronousQueue
- Inherits:
-
Object
- Object
- LogStash::Util::WrappedSynchronousQueue
- Defined in:
- lib/logstash/util/wrapped_synchronous_queue.rb
Instance Method Summary collapse
-
#initialize ⇒ WrappedSynchronousQueue
constructor
A new instance of WrappedSynchronousQueue.
-
#offer(obj, timeout_ms) ⇒ Boolean
Offer an object to the queue, wait for the specified amout of time.
-
#poll(millis) ⇒ Object
Block for X millis.
-
#push(obj) ⇒ Object
(also: #<<)
Push an object to the queue if the queue is full it will block until the object can be added to the queue.
-
#take ⇒ Object
Blocking.
Constructor Details
#initialize ⇒ WrappedSynchronousQueue
Returns a new instance of WrappedSynchronousQueue.
8 9 10 |
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 8 def initialize() @queue = java.util.concurrent.SynchronousQueue.new() end |
Instance Method Details
#offer(obj, timeout_ms) ⇒ Boolean
Offer an object to the queue, wait for the specified amout of time. If adding to the queue was successfull it wil return true, false otherwise.
27 28 29 |
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 27 def offer(obj, timeout_ms) @queue.offer(obj, timeout_ms, TimeUnit::MILLISECONDS) end |
#poll(millis) ⇒ Object
Block for X millis
37 38 39 |
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 37 def poll(millis) @queue.poll(millis, TimeUnit::MILLISECONDS) end |
#push(obj) ⇒ Object Also known as: <<
Push an object to the queue if the queue is full it will block until the object can be added to the queue.
16 17 18 |
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 16 def push(obj) @queue.put(obj) end |
#take ⇒ Object
Blocking
32 33 34 |
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 32 def take @queue.take() end |