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

Unsubscribe when thread is interrupted #1840

Merged
merged 1 commit into from
Jan 21, 2015

Conversation

roman-mazur
Copy link

Originated from discussion #1804.

I was considering to make it opt-in, but it would drastically increase number of methods in public API.
What do you think?

@roman-mazur roman-mazur force-pushed the unsubscribe-on-interrupt branch from 71996e7 to 773fe03 Compare November 10, 2014 10:37
@benjchristensen
Copy link
Member

I'll need to spend some time looking at this and it may not happen for 1.0, but I'll definitely spend time reviewing this. With a quick pass it looks okay, but due to the complexity of this use case I want to spend time playing with this code before merging.

Thank you very much for contributing this!

@roman-mazur
Copy link
Author

Let me know if I missed some blocking method.

@benjchristensen
Copy link
Member

I'm going to put this on the 1.1 list as I'm not ready to make a change like this right before releasing 1.0

@benjchristensen benjchristensen added this to the 1.1 milestone Nov 15, 2014
@roman-mazur
Copy link
Author

OK, thanks for looking at this.

On 11:59, Sat, Nov 15, 2014 Ben Christensen [email protected]
wrote:

I'm going to put this on the 1.1 list as I'm not ready to make a change
like this right before releasing 1.0


Reply to this email directly or view it on GitHub
#1840 (comment).

@@ -49,7 +50,7 @@ private BlockingOperatorLatest() {
@Override
public Iterator<T> iterator() {
LatestObserverIterator<T> lio = new LatestObserverIterator<T>();
source.materialize().subscribe(lio);
lio.subscription = source.materialize().subscribe(lio);
Copy link
Member

Choose a reason for hiding this comment

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

This set races with the dereference of L101 and may cause NPE. Besides, since it would be set to the value lio essentially (plus a transparent SafeSubscriber layer), you don't really need this field. Just call this.unsubscribe() on L101.

@roman-mazur roman-mazur force-pushed the unsubscribe-on-interrupt branch from 773fe03 to 31cb642 Compare January 20, 2015 12:24
@roman-mazur roman-mazur force-pushed the unsubscribe-on-interrupt branch from 31cb642 to 7020bcc Compare January 20, 2015 12:33
@roman-mazur
Copy link
Author

Edited per @akarnokd's remarks and rebased.

@akarnokd
Copy link
Member

Looks good to me now. Thanks.

akarnokd added a commit that referenced this pull request Jan 21, 2015
BlockingObservable: Unsubscribe when thread is interrupted
@akarnokd akarnokd merged commit cf5ae70 into ReactiveX:1.x Jan 21, 2015
@roman-mazur roman-mazur deleted the unsubscribe-on-interrupt branch January 21, 2015 15:23
@benjchristensen benjchristensen mentioned this pull request Feb 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants