All Downloads are FREE. Search and download functionalities are using the official Maven repository.

donky.microsoft.aspnet.signalr.client.UpdateableCancellableFuture Maven / Gradle / Ivy

There is a newer version: 2.7.0.3
Show newest version
/*
Copyright (c) Microsoft Open Technologies, Inc.
All Rights Reserved
See License.txt in the project root for license information.
*/

package donky.microsoft.aspnet.signalr.client;

/**
 * An updateable SignalRFuture that, when cancelled, triggers cancellation on an
 * internal instance
 */
public class UpdateableCancellableFuture extends SignalRFuture {
    SignalRFuture mFuture = null;

    Object mSync = new Object();

    public UpdateableCancellableFuture(SignalRFuture token) {
        mFuture = token;
    }

    public void setFuture(SignalRFuture token) {
        synchronized (mSync) {
            mFuture = token;
        }

        if (isCancelled()) {
            if (mFuture != null) {
                mFuture.cancel();
            }
        }
    }

    @Override
    public void cancel() {
        synchronized (mSync) {
            super.cancel();
            if (mFuture != null) {
                mFuture.cancel();
                mFuture = null;
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy