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

Fix #719: propagate cancellation to tasks in async Consumers #919

Merged
merged 4 commits into from Jul 10, 2019

Conversation

@oleg-py
Copy link
Collaborator

commented Jun 21, 2019

No description provided.

@oleg-py oleg-py requested a review from alexandru Jun 21, 2019

(out, AssignableCancelable.dummy)
(out, SingleAssignCancelable.plusOne(Cancelable { () =>
out.synchronized {
isDone = false

This comment has been minimized.

Copy link
@Avasil

Avasil Jul 2, 2019

Collaborator

Shouldn't this be isDone = true?

@@ -31,13 +31,22 @@ import scala.concurrent.Future
private[reactive] final class ForeachAsyncConsumer[A](f: A => Task[Unit]) extends Consumer[A, Unit] {

def createSubscriber(cb: Callback[Throwable, Unit], s: Scheduler): (Subscriber[A], AssignableCancelable) = {
var isDone = false
var lastCancelable = Cancelable.empty

val out = new Subscriber[A] {
implicit val scheduler = s
private[this] var isDone = false

This comment has been minimized.

Copy link
@Avasil

Avasil Jul 2, 2019

Collaborator

I think you've forgotten to remove it

@@ -43,7 +45,10 @@ private[reactive] final class MapTaskConsumer[In, R, R2](source: Consumer[In, R]
try {
val task = f(value)
streamErrors = false
task.runAsync(cb)
self.synchronized {
if (!isCancelled)

This comment has been minimized.

Copy link
@Avasil

Avasil Jul 2, 2019

Collaborator

I feel like we don't have to synchronize isCancelled if it's volatile (or it doesn't have to be volatile if it's only used in synchronized block)

This comment has been minimized.

Copy link
@oleg-py

oleg-py Jul 5, 2019

Author Collaborator

Yeah, I'm synchronizing access across two variables here. Volatile probably is redundant

@@ -30,7 +30,9 @@ private[reactive] final class MapTaskConsumer[In, R, R2](source: Consumer[In, R]
extends Consumer[In, R2] {

def createSubscriber(cb: Callback[Throwable, R2], s: Scheduler): (Subscriber[In], AssignableCancelable) = {
val asyncCallback = new Callback[Throwable, R] {
@volatile var lastCancelable: Cancelable = Cancelable.empty

This comment has been minimized.

Copy link
@Avasil

Avasil Jul 2, 2019

Collaborator

Does it have to be volatile?

@@ -24,6 +24,8 @@ import monix.execution.exceptions.DummyException
import monix.reactive.{BaseTestSuite, Consumer, Observable}
import scala.util.Failure

import monix.execution.atomic.Atomic

This comment has been minimized.

Copy link
@Avasil

Avasil Jul 2, 2019

Collaborator

unused import?

@Avasil
Avasil approved these changes Jul 6, 2019
@Avasil

This comment has been minimized.

Copy link
Collaborator

commented Jul 6, 2019

Missing scalafmtAll :D

@Avasil Avasil merged commit fe7697b into monix:master Jul 10, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.