Class: NewRelic::Agent::PipeChannelManager::Pipe
- Inherits:
-
Object
- Object
- NewRelic::Agent::PipeChannelManager::Pipe
- Defined in:
- lib/new_relic/agent/pipe_channel_manager.rb
Instance Attribute Summary collapse
-
#in ⇒ Object
Returns the value of attribute in.
-
#last_read ⇒ Object
readonly
Returns the value of attribute last_read.
-
#out ⇒ Object
Returns the value of attribute out.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize ⇒ Pipe
constructor
A new instance of Pipe.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ Pipe
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
#in ⇒ Object
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_read ⇒ Object (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 |
#out ⇒ Object
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
#close ⇒ Object
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
56 57 58 |
# File 'lib/new_relic/agent/pipe_channel_manager.rb', line 56 def closed? @out.closed? && @in.closed? end |
#read ⇒ Object
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 |