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

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Resolves #3956.

The issue is that if the scope is already closed in ZIO#foreachPar_ the forked effects will never run and will never complete the promise, resulting in non-termination.

Also restores the changes to remove the by name parameters from ZLayer to address early initialization issues.

Note that this PR is not binary compatible.

@adamgfraser adamgfraser requested review from iravid and jdegoes July 21, 2020 19:44
ZIO
.whenM(result.await.map(!_)) {
causes.get.flatMap(ZIO.halt(_))
.whenM(ZIO.foreach(fibers)(_.await).map(_.exists(!_.succeeded))) {
Copy link
Member

Choose a reason for hiding this comment

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

Nothing is awaiting the result with this change. Is it still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Deleted the old result and renamed failureTrigger to result.

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.

Looks great. It'd be great to maintain the inversion of control where the child fibers are responsible for signalling the parent fiber that the overall task is completed, because that saves an O(n) of fiber awaits, but we can improve that in a follow up.

@adamgfraser
Copy link
Contributor Author

Yes. I think that may require additional combinators because child fibers may never run at all if the scope is already closed so they may not be able to signal that the task is completed.

@iravid
Copy link
Member

iravid commented Jul 22, 2020

Makes sense!

@adamgfraser adamgfraser merged commit 7d733c2 into zio:master Jul 22, 2020
@adamgfraser adamgfraser deleted the zlayer branch July 22, 2020 14:29
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.

Program stuck when Layer return error

2 participants