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

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Following up on discussion in #1824, adds a timeoutFork method on ZIO that attempts to timeout an effect, but does not wait for the running effect to terminate. If the running effect does not complete before the timeout elapses a reference to the interrupting fiber will be returned, allowing the user to decide what further action to take (e.g. ignore it, wait a certain amount of time for it to succeed or else do something else).

This can be useful when the effect is potentially uninterruptible to avoid waiting indefinitely on the effect to complete and possible apply further logic in that case.

LGLO
LGLO previously approved these changes Sep 30, 2019
Copy link
Contributor

@LGLO LGLO left a comment

Choose a reason for hiding this comment

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

Looks good!

*/
final def timeoutFork(d: Duration): ZIO[R with Clock, E, Either[Fiber[E, A], A]] =
raceWith(ZIO.sleep(d))(
(exit, fiber) => ZIO.done(exit).map(Right(_)) <* fiber.interrupt,
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO could be a bit more readable if fiber is renamed to timeoutFiber.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

LGLO
LGLO previously approved these changes Sep 30, 2019
Copy link
Contributor

@LGLO LGLO left a comment

Choose a reason for hiding this comment

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

Still LGTM :)

jdegoes
jdegoes previously approved these changes Oct 1, 2019
Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

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

Excellent work. Should make small work of the other PR!

@jdegoes
Copy link
Member

jdegoes commented Oct 1, 2019

Oops, a few conflicts to resolve..,

@adamgfraser adamgfraser dismissed stale reviews from jdegoes and LGLO via dea3f4c October 1, 2019 15:57
@adamgfraser
Copy link
Contributor Author

Conflicts resolved.

@jdegoes jdegoes merged commit 0e13088 into zio:master Oct 1, 2019
@adamgfraser adamgfraser deleted the timeoutFork branch October 1, 2019 16:42
ghostdogpr pushed a commit that referenced this pull request Oct 1, 2019
* implement Cause.Meta

* fix access levels

* make case class final

* address review comments

* migrate tests to ZIO Test

* address review comments

* fix type

* fix another typo

* pass `Data` in from above

* implement flatMap

* implement flatten

* implement unsandbox via flatten

* apply nonFlaky only on JVM

* use jvm test aspect more

* try ignoring tests

* start reenabling tests

* remove unused import

* reenable more tests

* Add ZSchedule.elapsed example to docs (#1871)

* Add ZSchedule.elapsed example to docs

* ignore flaky supervision test (#1874)

* CircleCI improvements (#1859)

* CircleCI improvements

* CircleCI improvements, yaml fix

* CircleCI improvements, yaml fix 2

* CircleCI improvements, yaml fix 3

* Implement ZIO#timeoutFork (#1856)

* implement timeoutFork

* address review comments
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
* implement timeoutFork

* address review comments
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
* implement Cause.Meta

* fix access levels

* make case class final

* address review comments

* migrate tests to ZIO Test

* address review comments

* fix type

* fix another typo

* pass `Data` in from above

* implement flatMap

* implement flatten

* implement unsandbox via flatten

* apply nonFlaky only on JVM

* use jvm test aspect more

* try ignoring tests

* start reenabling tests

* remove unused import

* reenable more tests

* Add ZSchedule.elapsed example to docs (zio#1871)

* Add ZSchedule.elapsed example to docs

* ignore flaky supervision test (zio#1874)

* CircleCI improvements (zio#1859)

* CircleCI improvements

* CircleCI improvements, yaml fix

* CircleCI improvements, yaml fix 2

* CircleCI improvements, yaml fix 3

* Implement ZIO#timeoutFork (zio#1856)

* implement timeoutFork

* address review comments
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.

3 participants