Package org.apache.qpid.protonj2.engine
Class AMQPPerformativeEnvelopePool<E extends PerformativeEnvelope<Performative>>
- java.lang.Object
-
- org.apache.qpid.protonj2.engine.AMQPPerformativeEnvelopePool<E>
-
- Type Parameters:
E
- The type of Protocol Performative to pool incoming or outgoing.
public class AMQPPerformativeEnvelopePool<E extends PerformativeEnvelope<Performative>> extends Object
Pool ofPerformativeEnvelope
instances used to reduce allocations on incoming performatives.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_POOL_SIZE
The default maximum pool size to use if not otherwise configured.
-
Constructor Summary
Constructors Constructor Description AMQPPerformativeEnvelopePool(Function<AMQPPerformativeEnvelopePool<E>,E> envelopeBuilder)
Create a new envelope pool using the default pool size.AMQPPerformativeEnvelopePool(Function<AMQPPerformativeEnvelopePool<E>,E> envelopeBuilder, int maxPoolSize)
Create a new envelope pool using the default pool size.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxPoolSize()
static AMQPPerformativeEnvelopePool<IncomingAMQPEnvelope>
incomingEnvelopePool()
static AMQPPerformativeEnvelopePool<IncomingAMQPEnvelope>
incomingEnvelopePool(int maxPoolSize)
static AMQPPerformativeEnvelopePool<OutgoingAMQPEnvelope>
outgoingEnvelopePool()
static AMQPPerformativeEnvelopePool<OutgoingAMQPEnvelope>
outgoingEnvelopePool(int maxPoolSize)
E
take(Performative body, int channel, ProtonBuffer payload)
Requests an envelope from the pool and if non is available creates one using the given builder this pool was created with.
-
-
-
Field Detail
-
DEFAULT_MAX_POOL_SIZE
public static final int DEFAULT_MAX_POOL_SIZE
The default maximum pool size to use if not otherwise configured.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AMQPPerformativeEnvelopePool
public AMQPPerformativeEnvelopePool(Function<AMQPPerformativeEnvelopePool<E>,E> envelopeBuilder)
Create a new envelope pool using the default pool size.- Parameters:
envelopeBuilder
- The builder that will provide new envelope instances when the pool is empty.
-
AMQPPerformativeEnvelopePool
public AMQPPerformativeEnvelopePool(Function<AMQPPerformativeEnvelopePool<E>,E> envelopeBuilder, int maxPoolSize)
Create a new envelope pool using the default pool size.- Parameters:
envelopeBuilder
- The builder that will provide new envelope instances when the pool is empty.maxPoolSize
- The maximum number of envelopes to hold in the pool at any given time.
-
-
Method Detail
-
getMaxPoolSize
public final int getMaxPoolSize()
- Returns:
- the configured maximum pool size.
-
take
public E take(Performative body, int channel, ProtonBuffer payload)
Requests an envelope from the pool and if non is available creates one using the given builder this pool was created with.- Parameters:
body
- The body that will be stored in the envelope.channel
- The channel that is assigned to the envelope until returned to the pool.payload
- The Binary payload that is to be encoded with the given envelope body.- Returns:
- the envelope instance that was taken from the pool or created if the pool was empty.
-
incomingEnvelopePool
public static AMQPPerformativeEnvelopePool<IncomingAMQPEnvelope> incomingEnvelopePool(int maxPoolSize)
- Parameters:
maxPoolSize
- The maximum number of protocol envelopes to store in the pool.- Returns:
- a new
AMQPPerformativeEnvelopePool
that pools incoming AMQP envelopes
-
incomingEnvelopePool
public static AMQPPerformativeEnvelopePool<IncomingAMQPEnvelope> incomingEnvelopePool()
- Returns:
- a new
AMQPPerformativeEnvelopePool
that pools incoming AMQP envelopes
-
outgoingEnvelopePool
public static AMQPPerformativeEnvelopePool<OutgoingAMQPEnvelope> outgoingEnvelopePool(int maxPoolSize)
- Parameters:
maxPoolSize
- The maximum number of protocol envelopes to store in the pool.- Returns:
- a new
AMQPPerformativeEnvelopePool
that pools outgoing AMQP envelopes
-
outgoingEnvelopePool
public static AMQPPerformativeEnvelopePool<OutgoingAMQPEnvelope> outgoingEnvelopePool()
- Returns:
- a new
AMQPPerformativeEnvelopePool
that pools outgoing AMQP envelopes
-
-