@Override
    public boolean cancel() {
        while (!cancellableRef.isMarked()) {
            final Cancellable actualCancellable = cancellableRef.getReference();
            if (cancellableRef.compareAndSet(actualCancellable, actualCancellable, false, true)) {
                if (actualCancellable != null) {
                    actualCancellable.cancel();
                }
                return true;
            }
        }
        return false;
    }
Constructs a new instance with the given method and request URI.

@param method request method.
@param requestUri request URI.
httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.java