Class RecyclerAbstract

Keeps a depot of objects that have been marked for reuse, sorted by type.
Using Recycler reduces load on the carbage collector and thus supports smooth performance.

Author

Jirka Dell'Oro-Friedl, HFU, 2021

Link

https://github.com/hs-furtwangen/FUDGE/wiki/Recycler

Constructors

Methods

  • Emptys the depot of a given type, leaving the objects for the garbage collector. May result in a short stall when many objects were in

    Type Parameters

    • T

    Parameters

    • _t: (new () => T)
        • new (): T
        • Returns T

    Returns void

  • Emptys all depots, leaving all objects to the garbage collector. May result in a short stall when many objects were in

    Returns void

  • Fetches an object of the requested type from the depot, calls its recycle-method and returns it. If the depot for that type is empty it returns a new object of the requested type.

    Type Parameters

    Parameters

    • _t: (new () => T)

      The class identifier of the desired object

        • new (): T
        • Returns T

    Returns T

  • Fetches an object of the requested type from the depot and returns it. ⚠️DOES NOT call its recycle-method. Faster than Recycler.get, but should be used with caution.

    Type Parameters

    • T extends Object

    Parameters

    • _t: (new () => T)
        • new (): T
        • Returns T

    Returns T

  • Stores the object in the depot for later recycling. Users are responsible for throwing in objects that are about to loose scope and are not referenced by any other

    Parameters

    • _instance: Object

    Returns void