reactor-core/src/main/java/reactor/core/publisher/Operators.java
public static <F> boolean replace(AtomicReferenceFieldUpdater<F, Subscription> field,
			F instance,
			Subscription s) {
		for (; ; ) {
			Subscription a = field.get(instance);
			if (a == CancelledSubscription.INSTANCE) {
				s.cancel();
				return false;
			}
			if (field.compareAndSet(instance, a, s)) {
				return true;
			}
		}
	}
public static <F> boolean replace(AtomicReferenceFieldUpdater<F, Subscription> field,
			F instance,
			Subscription s) {
		for (; ; ) {
			Subscription a = field.get(instance);
			if (a == CancelledSubscription.INSTANCE) {
				s.cancel();
				return false;
			}
			if (field.compareAndSet(instance, a, s)) {
				return true;
			}
		}
	}
A generic utility to atomically replace a subscription or cancel the replacement
if the current subscription is marked as already cancelled (as in
{@link #cancelledSubscription()}).

@param field The Atomic container
@param instance the instance reference
@param s the subscription
@param <F> the instance type

@return true if replaced