net.i2p.router.tunnel

## Class TunnelGatewayPumper

- java.lang.Object
- - net.i2p.router.tunnel.TunnelGatewayPumper

- All Implemented Interfaces:
    Runnable

      class TunnelGatewayPumper
      extends Object
      implements Runnable

  TunnelGatewayPumper runs a pool of threads that process PumpedTunnelGateway instances which need messages pushed through preprocessing and sending. This class is thread-safe and designed to manage concurrent producers (calling wantsPumping) and multiple consumer threads (pumper threads). Shutdown coordination: - The stopPumping() method sets a stop flag and enqueues a special poison pill for each thread. - Threads detect the poison pill and exit cleanly. - Threads are interrupted and joined to ensure complete termination. Thread safety notes: - Uses a LinkedBlockingQueue with bounded capacity for backpressure. - Uses a concurrent Set to track backlogged gateways for requeueing. - Retry with blocking put() ensures no pump request is silently dropped. - Synchronization around stop flag prevents race conditions with producing new tasks.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TunnelGatewayPumper(RouterContext ctx)` Creates a new TunnelGatewayPumper and starts configured number of pump threads.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `run()` Primary thread run loop.
    `void` | `stopPumping()` Requests a graceful stop for pump threads.
    `void` | `wantsPumping(PumpedTunnelGateway gw)` Adds a PumpedTunnelGateway to be pumped, blocking if queue is full.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TunnelGatewayPumper

          public TunnelGatewayPumper(RouterContext ctx)

      Creates a new TunnelGatewayPumper and starts configured number of pump threads.
      Parameters:
        `ctx` - the router context

  - ### Method Detail

    - #### run

          public void run()

      Primary thread run loop. Picks gateways from the queue and pumps messages.
      Specified by:
        `run` in interface `Runnable`

    - #### stopPumping

          public void stopPumping()

      Requests a graceful stop for pump threads. Clears queues and signals all pump threads to terminate. Waits for thread termination before returning.

    - #### wantsPumping

          public void wantsPumping(PumpedTunnelGateway gw)

      Adds a PumpedTunnelGateway to be pumped, blocking if queue is full. No new requests are accepted after stopPumping() is called.
      Parameters:
        `gw` - the gateway to pump