Skip to content

Commit

Permalink
Switch orders of lazySet + dispose to flush
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Nov 27, 2017
1 parent ba8bd87 commit 9c3edf4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class AutoDisposingCompletableObserverImpl implements AutoDisposingComplet
@Override public void onSubscribe(final Disposable d) {
DisposableMaybeObserver<Object> o = new DisposableMaybeObserver<Object>() {
@Override public void onSuccess(Object o) {
AutoDisposableHelper.dispose(mainDisposable);
lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(mainDisposable);
}

@Override public void onError(Throwable e) {
Expand Down Expand Up @@ -76,16 +76,16 @@ final class AutoDisposingCompletableObserverImpl implements AutoDisposingComplet

@Override public void onComplete() {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onComplete();
}
}

@Override public void onError(Throwable e) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onError(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class AutoDisposingMaybeObserverImpl<T> implements AutoDisposingMaybeObser
@Override public void onSubscribe(final Disposable d) {
DisposableMaybeObserver<Object> o = new DisposableMaybeObserver<Object>() {
@Override public void onSuccess(Object o) {
AutoDisposableHelper.dispose(mainDisposable);
lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(mainDisposable);
}

@Override public void onError(Throwable e) {
Expand Down Expand Up @@ -76,24 +76,24 @@ final class AutoDisposingMaybeObserverImpl<T> implements AutoDisposingMaybeObser

@Override public void onSuccess(T value) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onSuccess(value);
}
}

@Override public void onError(Throwable e) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onError(e);
}
}

@Override public void onComplete() {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onComplete();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ final class AutoDisposingObserverImpl<T> extends AtomicInteger implements AutoDi
@Override public void onSubscribe(final Disposable d) {
DisposableMaybeObserver<Object> o = new DisposableMaybeObserver<Object>() {
@Override public void onSuccess(Object o) {
AutoDisposableHelper.dispose(mainDisposable);
lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(mainDisposable);
}

@Override public void onError(Throwable e) {
Expand Down Expand Up @@ -80,24 +80,24 @@ final class AutoDisposingObserverImpl<T> extends AtomicInteger implements AutoDi
if (!isDisposed()) {
if (HalfSerializer.onNext(delegate, value, this, error)) {
// Terminal event occurred and was forwarded to the delegate, so clean up here
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
}
}
}

@Override public void onError(Throwable e) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
HalfSerializer.onError(delegate, e, this, error);
}
}

@Override public void onComplete() {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
HalfSerializer.onComplete(delegate, this, error);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class AutoDisposingSingleObserverImpl<T> implements AutoDisposingSingleObs
@Override public void onSubscribe(final Disposable d) {
DisposableMaybeObserver<Object> o = new DisposableMaybeObserver<Object>() {
@Override public void onSuccess(Object o) {
AutoDisposableHelper.dispose(mainDisposable);
lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(mainDisposable);
}

@Override public void onError(Throwable e) {
Expand Down Expand Up @@ -76,16 +76,16 @@ final class AutoDisposingSingleObserverImpl<T> implements AutoDisposingSingleObs

@Override public void onSuccess(T value) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onSuccess(value);
}
}

@Override public void onError(Throwable e) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoDisposableHelper.dispose(lifecycleDisposable);
delegate.onError(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ final class AutoDisposingSubscriberImpl<T> extends AtomicInteger
@Override public void onSubscribe(final Subscription s) {
DisposableMaybeObserver<Object> o = new DisposableMaybeObserver<Object>() {
@Override public void onSuccess(Object o) {
AutoSubscriptionHelper.cancel(mainSubscription);
lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED);
AutoSubscriptionHelper.cancel(mainSubscription);
}

@Override public void onError(Throwable e) {
Expand Down Expand Up @@ -109,24 +109,24 @@ final class AutoDisposingSubscriberImpl<T> extends AtomicInteger
if (!isDisposed()) {
if (HalfSerializer.onNext(delegate, value, this, error)) {
// Terminal event occurred and was forwarded to the delegate, so clean up here
AutoDisposableHelper.dispose(lifecycleDisposable);
mainSubscription.lazySet(AutoSubscriptionHelper.CANCELLED);
AutoDisposableHelper.dispose(lifecycleDisposable);
}
}
}

@Override public void onError(Throwable e) {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainSubscription.lazySet(AutoSubscriptionHelper.CANCELLED);
AutoDisposableHelper.dispose(lifecycleDisposable);
HalfSerializer.onError(delegate, e, this, error);
}
}

@Override public void onComplete() {
if (!isDisposed()) {
AutoDisposableHelper.dispose(lifecycleDisposable);
mainSubscription.lazySet(AutoSubscriptionHelper.CANCELLED);
AutoDisposableHelper.dispose(lifecycleDisposable);
HalfSerializer.onComplete(delegate, this, error);
}
}
Expand Down

0 comments on commit 9c3edf4

Please sign in to comment.