java.lang.Object
net.i2p.router.transport.udp.PacketBuilder2.BlockPool
- Enclosing class:
PacketBuilder2
Per-thread pool of payload block objects and the reusable block list. Blocks are used only within
PacketBuilder2.buildPacket(List, List, SSU2Sender) for serialization and are never retained after the packet is built, so each thread can clear and refill its own pool across calls without synchronization.Field Summary
FieldsModifier and TypeFieldDescription(package private) final List<SSU2Payload.Block> The list passed to writePayload(); cleared and refilled per call.(package private) final List<SSU2Payload.FirstFragBlock> Pooled first fragment blocks ready for reuse.(package private) final List<SSU2Payload.FollowFragBlock> Pooled follow-on fragment blocks ready for reuse.(package private) final List<SSU2Payload.I2NPBlock> Pooled I2NP blocks ready for reuse.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescription(package private) SSU2Payload.FirstFragBlockTakes a first fragment block from the pool.(package private) SSU2Payload.FollowFragBlockacquireFollowFrag(OutboundMessageState state, int fragment) Takes a follow-on fragment block from the pool.(package private) SSU2Payload.I2NPBlockacquireI2NP(OutboundMessageState state) Takes an I2NP block from the pool.(package private) voidrelease(List<SSU2Payload.Block> used) Returns all the blocks to their type pools for reuse.
Field Details
blocks
The list passed to writePayload(); cleared and refilled per call.i2npBlocks
Pooled I2NP blocks ready for reuse.firstFragBlocks
Pooled first fragment blocks ready for reuse.followFragBlocks
Pooled follow-on fragment blocks ready for reuse.
Constructor Details
BlockPool
private BlockPool()Holds blocks ready for reuse.
Method Details
acquireI2NP
Takes an I2NP block from the pool.- Parameters:
state- the message state to fill in- Returns:
- a pooled block ready to fill in
acquireFirstFrag
Takes a first fragment block from the pool.- Parameters:
state- the message state to fill in- Returns:
- a pooled block ready to fill in
acquireFollowFrag
Takes a follow-on fragment block from the pool.- Parameters:
state- the message state to fill infragment- the fragment number to carry- Returns:
- a pooled block ready to fill in
release
Returns all the blocks to their type pools for reuse.- Parameters:
used- the blocks to return