digital-fabric / polyphony

Fine-grained concurrency for Ruby
https://www.rubydoc.info/gems/polyphony
MIT License
655 stars 17 forks source link

Implement custom Pipe class #83

Closed noteflakes closed 2 years ago

noteflakes commented 2 years ago

This class will encapsulate the two fds for a pipe, but allow usage directly in backend IO methods. Example usage:

def test_gzip
  src = Polyphony.pipe
  dest = Polyphony.pipe

  spin {
    IO.gzip(src, dest)
    dest.close
  }

  src << IO.read(__FILE__)
  src.close

  gz = Zlib::GzipReader.new(dest)
  data = gz.read
  assert_equal IO.read(__FILE__), data
end