Class: NewRelic::Agent::PipeChannelManager::Pipe

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/pipe_channel_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePipe

Returns a new instance of Pipe.



29
30
31
32
33
34
35
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 29

def initialize
  @out, @in = IO.pipe
  if defined?(::Encoding::ASCII_8BIT)
    @in.set_encoding(::Encoding::ASCII_8BIT)
  end
  @last_read = Time.now
end

Instance Attribute Details

#inObject

Returns the value of attribute in.



26
27
28
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 26

def in
  @in
end

#last_readObject (readonly)

Returns the value of attribute last_read.



27
28
29
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 27

def last_read
  @last_read
end

#outObject

Returns the value of attribute out.



26
27
28
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 26

def out
  @out
end

Instance Method Details

#closeObject



37
38
39
40
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 37

def close
  @out.close unless @out.closed?
  @in.close unless @in.closed?
end

#closed?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 56

def closed?
  @out.closed? && @in.closed?
end

#readObject



50
51
52
53
54
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 50

def read
  @in.close unless @in.closed?
  @last_read = Time.now
  @out.gets("\n\n")
end

#write(data) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 42

def write(data)
  @out.close unless @out.closed?
  @in << NewRelic::LanguageSupport.with_cautious_gc do
    Marshal.dump(data)
  end
  @in << "\n\n"
end