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/JirkaDellOro/FUDGE/wiki/Recycler

Constructors

Methods

  • Returns a reference to an object of the requested type in the depot, but does not remove it there. If no object of the requested type was in the depot, one is created, stored and borrowed. For short term usage of objects in a local scope, when there will be no other call to Recycler.get or .borrow!

    Type Parameters

    Parameters

    • _t: (new () => T)

      The class identifier of the desired object

        • new (): T
        • Returns T

    Returns T

  • 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

  • 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