Class VariablePool

java.lang.Object
org.wpilib.math.autodiff.VariablePool
All Implemented Interfaces:
AutoCloseable

public class VariablePool extends Object implements AutoCloseable
Cleans up implicitly allocated Variables via try-with-resources.

This implements a stack of Variable pools containing a default global pool. The user can create additional pools via try-with-resources. Variable and VariableMatrix instances will register themselves with the latest pool.

It's strongly recommended to only instantiate this class via try-with-resources so the close() methods are always called in the correct order (i.e., nested scopes).

  • Constructor Details

  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • register

      public static Variable register(Variable variable)
      Registers a Variable in the Variable stack for cleanup.
      Parameters:
      variable - The Variable to register
      Returns:
      The registered Variable