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 CancellableEffect typeclass. Use it to give races to IO #984

Merged
merged 43 commits into from Sep 15, 2018

Conversation

Projects
None yet
2 participants
@pakoito
Member

pakoito commented Aug 11, 2018

This PR races two IOs, allowing cancellation between them.

It also adds the typeclass CancellableEffect, that was needed to achieve this.

@pakoito pakoito requested review from raulraja and arrow-kt/maintainers Aug 11, 2018

@codecov

This comment has been minimized.

codecov bot commented Aug 12, 2018

Codecov Report

Merging #984 into master will decrease coverage by 0.63%.
The diff coverage is 43.95%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #984      +/-   ##
===========================================
- Coverage     47.03%   46.4%   -0.64%     
+ Complexity      694     692       -2     
===========================================
  Files           320     320              
  Lines          8091    8255     +164     
  Branches        848     859      +11     
===========================================
+ Hits           3806    3831      +25     
- Misses         3942    4080     +138     
- Partials        343     344       +1
Impacted Files Coverage Δ Complexity Δ
...s-rx2/src/main/kotlin/arrow/effects/ObservableK.kt 61.53% <0%> (-6.55%) 9 <0> (ø)
...cts-rx2/src/main/kotlin/arrow/effects/FlowableK.kt 50.63% <0%> (-3.43%) 9 <0> (ø)
...fects-rx2/src/main/kotlin/arrow/effects/SingleK.kt 73.33% <0%> (-14.67%) 6 <0> (ø)
...-test/src/main/kotlin/arrow/test/laws/MonadLaws.kt 48.33% <0%> (ø) 12 <1> (ø) ⬇️
...rc/main/kotlin/arrow/effects/FlowableKInstances.kt 57.14% <0%> (-2.12%) 0 <0> (ø)
.../src/main/kotlin/arrow/effects/SingleKInstances.kt 70% <0%> (-3.69%) 0 <0> (ø)
.../main/kotlin/arrow/effects/ObservableKInstances.kt 55.55% <0%> (-2.14%) 0 <0> (ø)
...rc/main/kotlin/arrow/effects/DeferredKInstances.kt 68.18% <0%> (-3.25%) 0 <0> (ø)
...effects/src/main/kotlin/arrow/effects/IORunLoop.kt 73.79% <100%> (-1.07%) 45 <0> (-2)
...w/effects/data/internal/IOCancellationException.kt 100% <100%> (ø) 1 <1> (ø) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f0c3c0...134c6c4. Read the comment docs.

pakoito and others added some commits Aug 21, 2018

@pakoito pakoito changed the title from [WIP] Add race to IO to Add CancellableEffect typeclass. Use it to give races to IO Sep 1, 2018

@pakoito

This comment has been minimized.

Member

pakoito commented Sep 1, 2018

@raulraja ready for review!

}
}
fun <A, B, C, D> IO.Companion.raceN(ctx: CoroutineContext, a: IO<A>, b: IO<B>, c: IO<C>, d: IO<D>): IO<Either<Either<A, B>, Either<C, D>>> =

This comment has been minimized.

@raulraja

raulraja Sep 2, 2018

Member

Hoping these would make it to a Concurrent type class in the near future.

import arrow.Kind
import arrow.core.Either
interface CancellableEffect<F> : Effect<F> {

This comment has been minimized.

@raulraja

raulraja Sep 2, 2018

Member

I believe this should be just Concurrent and include the race style algebra combinators in this type class so they are available for all concurrent effects in the spirit that concurrent effects are cancelable. For what is worth in cats we have:

Concurrent[F] extends Async[F]
ConcurrentEffect[F] extends Concurrent[F] with Effect[F]
@raulraja

This is definitely an improvement from what we have but I'm missing the type class aspect of race, etc.. which should live in my opinion in Concurrent just above Async in a similar way to how it's done in cats-effect

raulraja and others added some commits Sep 2, 2018

@pakoito pakoito merged commit ea2f788 into master Sep 15, 2018

4 checks passed

codecov/patch No report found to compare against
Details
codecov/project No report found to compare against
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@pakoito pakoito deleted the paco-ioraces branch Sep 15, 2018

@pakoito pakoito referenced this pull request Oct 11, 2018

Merged

Bracket #1043

7 of 7 tasks complete

@raulraja raulraja referenced this pull request Nov 2, 2018

Merged

Release 0.8.0 #1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment