class FutureObserver extends CountDownLatch implements Observer<T>, Future<T>, Disposable {

    @Override
    public void onError(Throwable t) {
        if (error == null) {
            error = t;

            for (;;) {
                Disposable a = s.get();
                if (a == this || a == DisposableHelper.DISPOSED) {
                    RxJavaPlugins.onError(t);
                    return;
                }
                if (s.compareAndSet(a, this)) {
                    countDown();
                    return;
                }
            }
        } else {
            RxJavaPlugins.onError(t);
        }
    }

    public  FutureObserver();

}