Sha256: 8b7bca3ffe8204aa74be4180e66ce4bc94f25c49bc5f47676f55ba3bcfbb08df
Contents?: true
Size: 897 Bytes
Versions: 16
Compression:
Stored size: 897 Bytes
Contents
module Appsignal class Pipe attr_reader :reader, :writer, :listener def initialize Appsignal.logger.debug "Initializing pipe in #{$$}" @reader, @writer = IO.pipe @listener = Thread.new do loop do Appsignal.agent.enqueue(Marshal::load(@reader)) end end @listening = true end def write(transaction) Marshal::dump(transaction, @writer) rescue IOError Appsignal.logger.debug "Broken pipe in #{$$}" Appsignal.agent.shutdown end def stop_listening! Thread.kill(@listener) @reader.close unless @reader.closed? @listening = false end def listening? !! @listening end class << self def init Thread.current[:appsignal_pipe] = Appsignal::Pipe.new end def current Thread.current[:appsignal_pipe] end end end end
Version data entries
16 entries across 16 versions & 1 rubygems