Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions reactive/kotlinx-coroutines-rx2/src/RxConvert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ public fun <T: Any> ObservableSource<T>.asFlow(): Flow<T> = callbackFlow {
}

subscribe(observer)
awaitClose { disposableRef.getAndSet(Disposed)?.dispose() }
}

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.

}

/**
Expand Down