reactor-core/src/main/java/reactor/util/concurrent/Queues.java
public static final int capacity(Queue q) {
		if (q instanceof ZeroQueue) {
			return 0;
		}
		if (q instanceof OneQueue) {
			return 1;
		}
		if (q instanceof SpscLinkedArrayQueue) {
			return Integer.MAX_VALUE;
		}
		else if (q instanceof SpscArrayQueue) {
			return ((SpscArrayQueue) q).length();
		}
		else if(q instanceof MpscLinkedQueue) {
			return Integer.MAX_VALUE;
		}
		else if (q instanceof BlockingQueue) {
			return ((BlockingQueue) q).remainingCapacity();
		}
		else if (q instanceof ConcurrentLinkedQueue) {
			return Integer.MAX_VALUE;
		}
		else {
			return CAPACITY_UNSURE;
		}
	}
public static final int capacity(Queue q) {
		if (q instanceof ZeroQueue) {
			return 0;
		}
		if (q instanceof OneQueue) {
			return 1;
		}
		if (q instanceof SpscLinkedArrayQueue) {
			return Integer.MAX_VALUE;
		}
		else if (q instanceof SpscArrayQueue) {
			return ((SpscArrayQueue) q).length();
		}
		else if(q instanceof MpscLinkedQueue) {
			return Integer.MAX_VALUE;
		}
		else if (q instanceof BlockingQueue) {
			return ((BlockingQueue) q).remainingCapacity();
		}
		else if (q instanceof ConcurrentLinkedQueue) {
			return Integer.MAX_VALUE;
		}
		else {
			return CAPACITY_UNSURE;
		}
	}
public static final int capacity ( Queue q ) { if ( q instanceof ZeroQueue ) { return 0 ; } if ( q instanceof OneQueue ) { return 1 ; } if ( q instanceof SpscLinkedArrayQueue ) { return Integer . MAX_VALUE ; } else if ( q instanceof SpscArrayQueue ) { return ( ( SpscArrayQueue ) q ) . length ( ) ; } else if ( q instanceof MpscLinkedQueue ) { return Integer . MAX_VALUE ; } else if ( q instanceof BlockingQueue ) { return ( ( BlockingQueue ) q ) . remainingCapacity ( ) ; } else if ( q instanceof ConcurrentLinkedQueue ) { return Integer . MAX_VALUE ; } else { return CAPACITY_UNSURE ; } }
Return the capacity of a given {@link Queue} in a best effort fashion. Queues that
are known to be unbounded will return {@code Integer.MAX_VALUE} and queues that
have a known bounded capacity will return that capacity. For other {@link Queue}
implementations not recognized by this method or not providing this kind of
information, {@link #CAPACITY_UNSURE} ({@code Integer.MIN_VALUE}) is returned.

@param q the {@link Queue} to try to get a capacity for
@return the capacity of the queue, if discoverable with confidence, or {@link #CAPACITY_UNSURE} negative constant.
Return the capacity of a given { @link Queue } in a best effort fashion . Queues that are known to be unbounded will return { @code Integer . MAX_VALUE } and queues that have a known bounded capacity will return that capacity . For other { @link Queue } implementations not recognized by this method or not providing this kind of information { @link #CAPACITY_UNSURE } ( { @code Integer . MIN_VALUE } ) is returned .