Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@simpadjo
Copy link
Contributor

closes #3491

@simpadjo simpadjo requested a review from iravid as a code owner May 16, 2020 23:31
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great.


def testStream(assertion: java.io.InputStream => TestResult): ZIO[Any, Nothing, TestResult] =
ZIO
.foreach(List(1, 2, 5, 30)) { chunkSize =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use a generator here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a generator and ended-up removing all my hand-written machinery.
Thanks!

import zio.{ Chunk, Exit, FiberFailure, ZIO }

private[zio] class ZInputStream(chunks: Iterator[Chunk[Byte]]) extends java.io.InputStream {
private var current: Iterator[Byte] = Iterator.empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of this and keep the current chunk and offsets in a var? This will box the bytes.

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

@simpadjo
Copy link
Contributor Author

@iravid thanks for kind words!
CI fails due to unrelated js stuff. Could you please merge?

@iravid iravid merged commit cee4781 into zio:master May 17, 2020
@simpadjo simpadjo deleted the bytestream branch June 5, 2020 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZStream#toInputStream creates a suboptimal InputStream

2 participants