Sha256: d7a435d5b13b5d8616ad28b19cabc509efe171aaaeef0c7b235e39c6a599be5b

Contents?: true

Size: 783 Bytes

Versions: 17

Compression:

Stored size: 783 Bytes

Contents

module Timber
  module LogDevices
    class HTTP
      # Works like SizedQueue, but drops message instead of blocking. Pass one of these in
      # to {HTTP#intiialize} via the :request_queue option if you'd prefer to drop messages
      # in the event of a buffer overflow instead of applying back pressure.
      class DroppingSizedQueue < SizedQueue
        # Returns true/false depending on whether the queue is full or not
        def push(obj)
          @mutex.synchronize do
            return false unless @que.length < @max

            @que.push obj
            begin
              t = @waiting.shift
              t.wakeup if t
            rescue ThreadError
              retry
            end
            return true
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
timber-2.1.10 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.9 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.8 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.7 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.6 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.5 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.4 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.3 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.2 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.1 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc6 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc5 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc4 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc3 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc2 lib/timber/log_devices/http/dropping_sized_queue.rb
timber-2.1.0.rc1 lib/timber/log_devices/http/dropping_sized_queue.rb