java.lang.Object
net.i2p.router.transport.udp.PacketBuilder2.BlockPool
Enclosing class:
PacketBuilder2

private static final class PacketBuilder2.BlockPoolextends Object
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 Details

  • 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

      SSU2Payload.FollowFragBlock acquireFollowFrag(OutboundMessageState state, int fragment)
      Takes a follow-on fragment block from the pool.
      Parameters:
      state - the message state to fill in
      fragment - the fragment number to carry
      Returns:
      a pooled block ready to fill in
    • release

      void release(List<SSU2Payload.Block> used)
      Returns all the blocks to their type pools for reuse.
      Parameters:
      used - the blocks to return