Class: LogStash::Util::WrappedSynchronousQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/util/wrapped_synchronous_queue.rb

Defined Under Namespace

Classes: ReadBatch, ReadClient, WriteBatch, WriteClient

Instance Method Summary collapse

Constructor Details

#initializeWrappedSynchronousQueue

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

#closeObject



49
50
51
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 49

def close
  # ignore
end

#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.

Parameters:

  • Object (Object)

    to add to the queue

  • Time (Integer)

    in milliseconds to wait before giving up

Returns:

  • (Boolean)

    True if adding was successfull if not it return false



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.

Parameters:

  • Object (Object)

    to add to the queue



16
17
18
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 16

def push(obj)
  @queue.put(obj)
end

#read_clientObject



45
46
47
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 45

def read_client
  ReadClient.new(self)
end

#takeObject

Blocking



32
33
34
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 32

def take
  @queue.take
end

#write_clientObject



41
42
43
# File 'lib/logstash/util/wrapped_synchronous_queue.rb', line 41

def write_client
  WriteClient.new(self)
end