Class: Async::HTTP::Body::Pipe
- Inherits:
-
Object
- Object
- Async::HTTP::Body::Pipe
- Defined in:
- lib/async/http/body/pipe.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(input, output = Writable.new, task: Task.current) ⇒ Pipe
constructor
If the input stream is closed first, it’s likely the output stream will also be closed.
- #to_io ⇒ Object
Constructor Details
#initialize(input, output = Writable.new, task: Task.current) ⇒ Pipe
If the input stream is closed first, it’s likely the output stream will also be closed.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/async/http/body/pipe.rb', line 30 def initialize(input, output = Writable.new, task: Task.current) @input = input @output = output head, tail = IO::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) @head = IO::Stream.new(head) @tail = tail @reader = nil @writer = nil task.async(&self.method(:reader)) task.async(&self.method(:writer)) end |
Instance Method Details
#close ⇒ Object
50 51 52 53 54 55 |
# File 'lib/async/http/body/pipe.rb', line 50 def close @reader&.stop @writer&.stop @tail.close end |
#to_io ⇒ Object
46 47 48 |
# File 'lib/async/http/body/pipe.rb', line 46 def to_io @tail end |