private author suo
  class CacheManager { /**
     * 单次清理检测允许执行的时间，单位ms。
     */ public static loopTimeLimit : number = 2 ; private private static _cacheList : any [ ] = [ ] ; private private static _index : number = 0 ; public constructor ( ) { } param disposeFunction param getCacheListFunction public static regCacheByFunction ( disposeFunction , getCacheListFunction ) { this . unRegCacheByFunction ( disposeFunction , getCacheListFunction ) ; var cache ; cache = { tryDispose : disposeFunction , getCacheList : getCacheListFunction } ; this . _cacheList . push ( cache ) ; } param disposeFunction param getCacheListFunction public static unRegCacheByFunction ( disposeFunction , getCacheListFunction ) { var i , len ; len = this . _cacheList . length ; for ( i = 0 ; i < len ; i ++ ) { if ( this . _cacheList [ i ] . tryDispose == disposeFunction && this . _cacheList [ i ] . getCacheList == getCacheListFunction ) { this . _cacheList . splice ( i , 1 ) ; return ; } } } /**
     * 强制清理所有管理器
     *
     */ public static forceDispose ( ) { var i , len = this . _cacheList . length ; for ( i = 0 ; i < len ; i ++ ) { this . _cacheList [ i ] . tryDispose ( true ) ; } } param waitTime public static beginCheck ( waitTime = 15000 ) { } /**
     * 停止检测循环
     *
     */ public static stopCheck ( ) { } private private static _checkLoop ( ) { var cacheList = this . _cacheList ; if ( cacheList . length < 1 ) return ; var tTime = Date . now ( ) ; var count ; var len ; len = count = cacheList . length ; while ( count > 0 ) { this . _index ++ ; this . _index = this . _index % len ; cacheList [ this . _index ] . tryDispose ( false ) ; if ( Date . now ( ) - tTime > this . loopTimeLimit ) break ; count -- ; } } }