Class Unpool<E>

java.lang.Object
de.tomatengames.util.pool.Unpool<E>
Type Parameters:
E - The type of object provided by this Unpool.
All Implemented Interfaces:
Pool<E>

public class Unpool<E> extends Object implements Pool<E>
The Unpool class implements the Pool interface but does not actually pool objects. It merely wraps the underlying supplier, so it creates new pooled instances each time an object is claimed.

Freeing its Pooled objects does nothing as there is no store of pooled objects.

Since:
1.8
  • Constructor Details

    • Unpool

      public Unpool(Supplier<E> factory)
      Constructs a new Unpool with the specified supplier for creating objects.
      Parameters:
      factory - A supplier function that provides instances of type E.
  • Method Details

    • claim

      public Pooled<E> claim()
      Claims a new instance of type E by using the underlying supplier.

      The claimed object is not pooled and will be created anew each time. The Pooled.free() method of the returned Pooled instance does nothing.

      Specified by:
      claim in interface Pool<E>
      Returns:
      A Pooled instance wrapping the newly created object.