Esempio n. 1
0
        public void Start(
            string downloadRoot,
            IAssetFileDatabase database,
            int parallelDownloadCount     = 16,
            int downloadRetryCount        = 3,
            int timeoutSeconds            = 30,
            int fileWriteBufferSize       = 16 * 1024 * 1024,
            int downloadHandlerBufferSize = 16 * 1024)
        {
            if (IsStarted())
            {
                Debug.LogWarning("Kayac.Loader.Start() called twice.");
                return;
            }
            _storageCache.Start(database);
            _fileWriter = new FileWriter(
                _storageCache.root,
                StorageCache.temporaryFilePostfix,
                fileWriteBufferSize);

            _downloadRetryCount    = downloadRetryCount;
            _parallelDownloadCount = parallelDownloadCount;
            _timeoutSeconds        = timeoutSeconds;
            _database     = database;
            _downloadRoot = downloadRoot + "/";

            _downloadHandlerBuffers = new byte[_parallelDownloadCount][];
            for (int i = 0; i < _parallelDownloadCount; i++)
            {
                _downloadHandlerBuffers[i] = new byte[downloadHandlerBufferSize];
            }

            _assetHandles             = new Dictionary <string, AssetHandle>();
            _watchingAssetHandles     = new List <AssetHandle>();
            _memoryCachedAssetHandles = new LinkedList <AssetHandle>();

            _downloadHandles        = new Dictionary <string, DownloadHandle>();
            _waitingDownloadHandles = new LinkedList <DownloadHandle>();
            _goingDownloadHandles   = new DownloadHandle[_parallelDownloadCount];           // 固定的に取り、バッファとの対応を固定化する

            _fileHandles               = new Dictionary <string, FileHandle>();
            _watchingFileHandles       = new List <FileHandle>();
            _watchingFileHandleAddList = new List <FileHandle>();
        }
Esempio n. 2
0
        public Loader(
            string downloadRoot,
            string storageCacheRoot,
            IAssetFileDatabase database,
            int parallelDownloadCount     = 16,
            int downloadRetryCount        = 3,
            int timeoutSeconds            = 30,
            int fileWriteBufferSize       = 16 * 1024 * 1024,
            int downloadHandlerBufferSize = 16 * 1024)
        {
            _storageCache = new StorageCache(storageCacheRoot, database);
            _fileWriter   = new FileWriter(
                storageCacheRoot,
                StorageCache.temporaryFilePostfix,
                fileWriteBufferSize);

            _downloadRetryCount    = downloadRetryCount;
            _parallelDownloadCount = parallelDownloadCount;
            _timeoutSeconds        = timeoutSeconds;
            _database     = database;
            _downloadRoot = downloadRoot + "/";

            _downloadHandlerBuffers = new byte[_parallelDownloadCount][];
            for (int i = 0; i < _parallelDownloadCount; i++)
            {
                _downloadHandlerBuffers[i] = new byte[downloadHandlerBufferSize];
            }

            _assetHandles         = new Dictionary <string, AssetHandle>();
            _watchingAssetHandles = new List <AssetHandle>();

            _downloadHandles        = new Dictionary <string, DownloadHandle>();
            _waitingDownloadHandles = new LinkedList <DownloadHandle>();
            _goingDownloadHandles   = new DownloadHandle[_parallelDownloadCount];           // 固定的に取り、バッファとの対応を固定化する

            _fileHandles         = new Dictionary <string, FileHandle>();
            _watchingFileHandles = new List <FileHandle>();
        }