Package reactor.util.concurrent
Class Queues
java.lang.Object
reactor.util.concurrent.Queues
Queue utilities and suppliers for 1-producer/1-consumer ready queues adapted for
various given capacities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intA small default of available slots in a given container, compromise between intensive pipelines, small subscribers numbers and memory use.static final intAn allocation friendly default of available slots in a given container, e.g. -
Method Summary
Modifier and TypeMethodDescriptionstatic intReturn the capacity of a givenQueuein a best effort fashion.static intceilingNextPowerOfTwo(int x) Calculate the next power of 2, greater than or equal to x.empty()get(int batchSize) static booleanisPowerOfTwo(int x) one()small()unbounded(int linkSize) Returns an unbounded, linked-array-based Queue.Returns an unbounded queue suitable for multi-producer/single-consumer (MPSC) scenarios.xs()
-
Field Details
-
CAPACITY_UNSURE
public static final int CAPACITY_UNSURE- See Also:
-
XS_BUFFER_SIZE
public static final int XS_BUFFER_SIZEAn allocation friendly default of available slots in a given container, e.g. slow publishers and or fast/few subscribers -
SMALL_BUFFER_SIZE
public static final int SMALL_BUFFER_SIZEA small default of available slots in a given container, compromise between intensive pipelines, small subscribers numbers and memory use.
-
-
Method Details
-
capacity
Return the capacity of a givenQueuein a best effort fashion. Queues that are known to be unbounded will returnInteger.MAX_VALUEand queues that have a known bounded capacity will return that capacity. For otherQueueimplementations not recognized by this method or not providing this kind of information,CAPACITY_UNSURE(Integer.MIN_VALUE) is returned.- Parameters:
q- theQueueto try to get a capacity for- Returns:
- the capacity of the queue, if discoverable with confidence, or
CAPACITY_UNSUREnegative constant.
-
ceilingNextPowerOfTwo
public static int ceilingNextPowerOfTwo(int x) Calculate the next power of 2, greater than or equal to x.From Hacker's Delight, Chapter 3, Harry S. Warren Jr.
- Parameters:
x- Value to round up- Returns:
- The next power of 2 from x inclusive
-
get
-
isPowerOfTwo
public static boolean isPowerOfTwo(int x) - Parameters:
x- the int to test- Returns:
- true if x is a power of 2
-
empty
-
one
-
small
-
unbounded
-
unbounded
Returns an unbounded, linked-array-based Queue. Integer.max sized link will return the defaultSMALL_BUFFER_SIZEsize. -
xs
-
unboundedMultiproducer
Returns an unbounded queue suitable for multi-producer/single-consumer (MPSC) scenarios.
-