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

Reuse RxJava built-in disposed Disposable #1841

Merged
merged 1 commit into from
Mar 4, 2020
Merged

Reuse RxJava built-in disposed Disposable #1841

merged 1 commit into from
Mar 4, 2020

Conversation

JakeWharton
Copy link
Contributor

No description provided.

@qwwdfsad qwwdfsad self-requested a review March 4, 2020 15:05
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

Thanks!

@qwwdfsad qwwdfsad merged commit 8d8a8fb into Kotlin:develop Mar 4, 2020
private object Disposed : Disposable {
override fun isDisposed() = true
override fun dispose() = Unit
awaitClose { disposableRef.getAndSet(Disposables.disposed())?.dispose() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I treated this private object Disposed as a private "token" similarly to DisposableHelper.DISPOSED in Rx itself (they have the warning there "don't leak it"), but here I didn't do compareAndSet(Disposed, ...) because comparing to initial null was enough, so I think your change is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Just trying to save APK size anywhere I can by reusing existing stuff.

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.

None yet

3 participants