Sha256: c8f66be0ad6f90d1b4d1fa23c98d50f90196b1a41dfb522af8a72ab260ab8671

Contents?: true

Size: 1.13 KB

Versions: 53

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

module LogStash; module Util
  class WrappedSynchronousQueue
    java_import java.util.concurrent.SynchronousQueue
    java_import java.util.concurrent.TimeUnit

    def initialize()
      @queue = java.util.concurrent.SynchronousQueue.new()
    end

    # Push an object to the queue if the queue is full
    # it will block until the object can be added to the queue.
    #
    # @param [Object] Object to add to the queue
    def push(obj)
      @queue.put(obj)
    end
    alias_method(:<<, :push)

    # 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.
    #
    # @param [Object] Object to add to the queue
    # @param [Integer] Time in milliseconds to wait before giving up
    # @return [Boolean] True if adding was successfull if not it return false
    def offer(obj, timeout_ms)
      @queue.offer(obj, timeout_ms, TimeUnit::MILLISECONDS)
    end

    # Blocking
    def take
      @queue.take()
    end

    # Block for X millis
    def poll(millis)
      @queue.poll(millis, TimeUnit::MILLISECONDS)
    end
  end
end end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/lib/logstash/util/wrapped_synchronous_queue.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/logstash-core-2.4.1-java/lib/logstash/util/wrapped_synchronous_queue.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/logstash-core-2.4.1-java/lib/logstash/util/wrapped_synchronous_queue.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/logstash-core-2.4.1-java/lib/logstash/util/wrapped_synchronous_queue.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/logstash-core-2.4.1-java/lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.1-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.0-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.0.snapshot4-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.0.snapshot3-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.0.snapshot2-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.4.0.snapshot1-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.3.4-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.3.4.snapshot1-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-5.0.0.alpha4.snapshot3-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-5.0.0.alpha4.snapshot2-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.3.3-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-2.3.3.snapshot2-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-5.0.0.alpha4.snapshot1-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-5.0.0.alpha3-java lib/logstash/util/wrapped_synchronous_queue.rb
logstash-core-5.0.0.alpha3.snapshot8-java lib/logstash/util/wrapped_synchronous_queue.rb