ResourcePool

source

Manages retention of pooled resources.

Constructors

new ResourcePool<T extends Disposable>(instanceConstructor: Function): ResourcePoolsource

Properties

readonlyinstanceConstructor: Functionsource

readonlyinstanceMap: Map<StringHash, ControlBlock<T>>source

Methods

Static methods

staticcollect(): voidsource

staticforType<T extends Function>(type: T): ResourcePoolsource

Gets the resource pool for a given type.

staticgetPersistent<T extends Function>(type: T, args: ConstructorParameters<T>): Handlesource

Gets a persistent Handle to a resource. Pass the constructor arguments for that resource. If an existing instance exists that matches those arguments, a new handle is returned that points to that instance; if no such instance exists, one is constructed.

staticgetTemporary<T extends Function>(type: T, args: ConstructorParameters<T>): InstanceType<T>source

Gets a reference to a resource. Pass the constructor arguments for that resource. If an existing instance exists that matches those arguments, a new handle is returned that points to that instance; if no such instance exists, one is constructed. Use this if the reference does not need to be retained.

Instance methods

getOrInstantiate(args: any[]): ControlBlock<T>source

getPersistent(args: any[]): Handlesource

getTemporary(args: any[]): Tsource