Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readOutputStream combinator in fs2-io #1648

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

Daenyth
Copy link
Contributor

@Daenyth Daenyth commented Oct 3, 2019

I still need to finalize the unit tests - I copied what was in my gist with minor adaptations, needs cleaning still

Close #1641

@Daenyth Daenyth force-pushed the read-outputstream branch from f91d6fb to eb13341 Compare October 4, 2019 20:32
@mpilquist
Copy link
Member

@Daenyth Anything left on this one? It's still marked as a draft.

@Daenyth
Copy link
Contributor Author

Daenyth commented Oct 11, 2019

I swear the tests were failing, but it's green now and I haven't changed anything. I have no idea what's up there.

@Daenyth Daenyth marked this pull request as ready for review October 11, 2019 17:15
@Daenyth
Copy link
Contributor Author

Daenyth commented Oct 11, 2019

@mpilquist should be good to go now that it's green

@mpilquist mpilquist merged commit 50230d3 into typelevel:master Oct 14, 2019
@nigredo-tori
Copy link
Contributor

nigredo-tori commented Oct 14, 2019

About the failing tests, I'll repeat it here so it doesn't get lost: it looks like the first test can deadlock on a single-thread ContextShift, since it writes without shifting to blocker. This can be flaky, since for a deadlock it needs to overflow the pipe, and that should only happen with a sufficiently large generated array (IIRC, over 1KB).


Stream.resource(mkOutput).flatMap {
case (os, is) =>
val write = f(os) *> Sync[F].delay(os.close())
Copy link
Member

Choose a reason for hiding this comment

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

Use blocker.delay here instead

) { (bytes: Array[Byte], chunkSize: Int) =>
Blocker[IO].use { blocker =>
readOutputStream[IO](blocker, chunkSize)(
(os: OutputStream) => IO(os.write(bytes))
Copy link
Member

Choose a reason for hiding this comment

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

Use blocker.delay[IO] instead (h/t @nigredo-tori)

@mpilquist mpilquist added this to the 2.1.0 milestone Nov 5, 2019
@Daenyth Daenyth deleted the read-outputstream branch November 5, 2019 18:13
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.

Add a combinator for (OutputStream => Unit) => Stream[F, Byte]
3 participants