Sha256: a7b2a1766653a54494e9474e8ac55497bf925403c6fab859d9a5856fd697b94c

Contents?: true

Size: 532 Bytes

Versions: 3

Compression:

Stored size: 532 Bytes

Contents

require 'thread'

require_relative 'base'


module Anschel
  class Output
    class Device < Base
      def initialize config, stats, log
        path   = config.delete(:path) || '/dev/stdout'
        qsize  = config.delete(:queue_size) || 2000
        @queue = SizedQueue.new qsize

        @thread = Thread.new do
          File.open(path, 'w') do |f|
            loop do
              f.puts @queue.shift
              f.flush
              stats.inc 'output'
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
anschel-0.7.19 lib/anschel/output/device.rb
anschel-0.7.18 lib/anschel/output/device.rb
anschel-0.7.17 lib/anschel/output/device.rb