license import { HashTableMap , NamedTensorMap } from '../data/types' ; import { HashTable } from './hash_table' ; /**
 * Contains global resources of a model.
 */ export class ResourceManager { constructor ( readonly hashTableNameToHandle = { } , readonly hashTableMap = { } ) { } param name param hashTable addHashTable ( name , hashTable ) { this . hashTableNameToHandle [ name ] = hashTable . handle ; this . hashTableMap [ hashTable . id ] = hashTable ; } param name getHashTableHandleByName ( name ) { return this . hashTableNameToHandle [ name ] ; } param id getHashTableById ( id ) { return this . hashTableMap [ id ] ; } /**
     * Dispose `ResourceManager`, including its hashTables and tensors in them.
     */ dispose ( ) { for ( const key in this . hashTableMap ) { this . hashTableMap [ key ] . clearAndClose ( ) ; delete this . hashTableMap [ key ] ; } for ( const name in this . hashTableNameToHandle ) { this . hashTableNameToHandle [ name ] . dispose ( ) ; delete this . hashTableNameToHandle [ name ] ; } } }