-
-
Couldn't load subscription status.
- Fork 244
Change Task to sequence (back-pressure) async finalizers #726
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
Conversation
| * cancelling everything when `cancel` gets evaluated. | ||
| */ | ||
| def collection[F[_]](refs: CancelableF[F]*)(implicit F: Sync[F]): CancelableF[F] = | ||
| unsafeApply[F](cancelAll(refs:_*)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be @UnsafeBecauseImpure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual implementation has no state. Should it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if it's unsafe, I'd rather wrap it in F[_], but figured there's no point in doing it.
Not sure if I'm right. Maybe I should just wrap it in F[_] to be on the safe side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the unsafeApply allocates mutable state, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, yes, that's a good point. I think my intention was to use wrap, because CancelableF references have to ensure idempotency on their own, no extra protections needed for such a "collection".
Thanks for pointing it out, definitely needs a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad it helped 👍
Codecov Report
@@ Coverage Diff @@
## master #726 +/- ##
==========================================
+ Coverage 90.57% 90.82% +0.25%
==========================================
Files 392 398 +6
Lines 11007 11133 +126
Branches 2050 2077 +27
==========================================
+ Hits 9970 10112 +142
+ Misses 1037 1021 -16 |
17dd31a to
3dc0fba
Compare
This change is related to the changes I also did in Cats-Effect's
IOimplementation, see:Taskchanges to sequence async finalizers, specified viabracketor viaTask.cancelable. What this means is that:Task[Unit]is used, in addition toCancelablevalues for specifying finalizersTaskvaluesrunAsyncvariants:runAsyncFthat returns aTask[Unit](aliasedCancelToken[Task])runAsyncAndForget, an optimized way to run tasks in cases in which we care not about the result or about cancelling itrunAsyncUncancelable, which doesn't return a cancellation tokenrunAsyncMaybe(which was useless)I also started a new sub-project of Monix called
monix-catnap. This will provide utilities built on Cats-Effect's type classes. And the first traits introduced are:monix.catnap.CancelableFmonix.catnap.cancelables.BooleanCancelableFI don't have time to introduce pure versions of all cancelable types in
monix.execution, but that's the plan. I also plan to introduce specializedRefimplementations, like we have inmonix.execution.atomic. Socatnapintends to provide generic and pure equivalents for what we have inexecution.