From 087216b9da914866c28dc718c04dcd5d3e790498 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 17 Jul 2023 19:43:41 +0800 Subject: [PATCH] update runtime code --- .../Runtime/CacheSystem/CacheSystem.cs | 4 +-- .../Internal/FindCacheFilesOperation.cs | 6 ++--- .../Internal/VerifyCacheFilesOperation.cs | 26 +++++++++---------- .../Internal/VerifyTempFileOperation.cs | 14 +++++----- .../Runtime/CacheSystem/VerifyElement.cs | 8 +++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index 6f3b87e..948a2da 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -93,7 +93,7 @@ namespace YooAsset /// /// 验证缓存文件(子线程内操作) /// - public static EVerifyResult VerifyingCacheFile(VerifyCacheElement element) + public static EVerifyResult VerifyingCacheFile(VerifyCacheFileElement element) { try { @@ -125,7 +125,7 @@ namespace YooAsset /// /// 验证下载文件(子线程内操作) /// - public static EVerifyResult VerifyingTempFile(VerifyTempElement element) + public static EVerifyResult VerifyingTempFile(VerifyTempFileElement element) { return VerifyingInternal(element.TempDataFilePath, element.FileSize, element.FileCRC, EVerifyLevel.High); } diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs index d98bd95..f2987e9 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs @@ -25,7 +25,7 @@ namespace YooAsset /// /// 需要验证的元素 /// - public readonly List VerifyElements = new List(5000); + public readonly List VerifyElements = new List(5000); public FindCacheFilesOperation(string packageName) { @@ -113,7 +113,7 @@ namespace YooAsset string fileRootPath = chidDirectory.FullName; string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}"; string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}"; - VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath); + VerifyCacheFileElement element = new VerifyCacheFileElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath); VerifyElements.Add(element); } @@ -161,7 +161,7 @@ namespace YooAsset string fileRootPath = chidDirectory.FullName; string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}{dataFileExtension}"; string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}"; - VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath); + VerifyCacheFileElement element = new VerifyCacheFileElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath); VerifyElements.Add(element); } diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyCacheFilesOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyCacheFilesOperation.cs index 0ab4d61..9266a4f 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyCacheFilesOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyCacheFilesOperation.cs @@ -8,7 +8,7 @@ namespace YooAsset { internal abstract class VerifyCacheFilesOperation : AsyncOperationBase { - public static VerifyCacheFilesOperation CreateOperation(List elements) + public static VerifyCacheFilesOperation CreateOperation(List elements) { #if UNITY_WEBGL var operation = new VerifyCacheFilesWithoutThreadOperation(elements); @@ -33,8 +33,8 @@ namespace YooAsset } private readonly ThreadSyncContext _syncContext = new ThreadSyncContext(); - private List _waitingList; - private List _verifyingList; + private List _waitingList; + private List _verifyingList; private int _verifyMaxNum; private int _verifyTotalCount; private float _verifyStartTime; @@ -42,7 +42,7 @@ namespace YooAsset private int _failedCount; private ESteps _steps = ESteps.None; - public VerifyCacheFilesWithThreadOperation(List elements) + public VerifyCacheFilesWithThreadOperation(List elements) { _waitingList = elements; } @@ -68,7 +68,7 @@ namespace YooAsset if (_verifyMaxNum < 1) _verifyMaxNum = 1; - _verifyingList = new List(_verifyMaxNum); + _verifyingList = new List(_verifyMaxNum); _steps = ESteps.UpdateVerify; } @@ -114,19 +114,19 @@ namespace YooAsset return 1f; return (float)(_succeedCount + _failedCount) / _verifyTotalCount; } - private bool BeginVerifyFileWithThread(VerifyCacheElement element) + private bool BeginVerifyFileWithThread(VerifyCacheFileElement element) { return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element); } private void VerifyInThread(object obj) { - VerifyCacheElement element = (VerifyCacheElement)obj; + VerifyCacheFileElement element = (VerifyCacheFileElement)obj; element.Result = CacheSystem.VerifyingCacheFile(element); _syncContext.Post(VerifyCallback, element); } private void VerifyCallback(object obj) { - VerifyCacheElement element = (VerifyCacheElement)obj; + VerifyCacheFileElement element = (VerifyCacheFileElement)obj; _verifyingList.Remove(element); if (element.Result == EVerifyResult.Succeed) @@ -158,8 +158,8 @@ namespace YooAsset Done, } - private List _waitingList; - private List _verifyingList; + private List _waitingList; + private List _verifyingList; private int _verifyMaxNum; private int _verifyTotalCount; private float _verifyStartTime; @@ -167,7 +167,7 @@ namespace YooAsset private int _failedCount; private ESteps _steps = ESteps.None; - public VerifyCacheFilesWithoutThreadOperation(List elements) + public VerifyCacheFilesWithoutThreadOperation(List elements) { _waitingList = elements; } @@ -189,7 +189,7 @@ namespace YooAsset _verifyMaxNum = fileCount; _verifyTotalCount = fileCount; - _verifyingList = new List(_verifyMaxNum); + _verifyingList = new List(_verifyMaxNum); _steps = ESteps.UpdateVerify; } @@ -229,7 +229,7 @@ namespace YooAsset return 1f; return (float)(_succeedCount + _failedCount) / _verifyTotalCount; } - private void BeginVerifyFileWithoutThread(VerifyCacheElement element) + private void BeginVerifyFileWithoutThread(VerifyCacheFileElement element) { element.Result = CacheSystem.VerifyingCacheFile(element); if (element.Result == EVerifyResult.Succeed) diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyTempFileOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyTempFileOperation.cs index 9539d59..7f7decd 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyTempFileOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/VerifyTempFileOperation.cs @@ -10,7 +10,7 @@ namespace YooAsset { public EVerifyResult VerifyResult { protected set; get; } - public static VerifyTempFileOperation CreateOperation(VerifyTempElement element) + public static VerifyTempFileOperation CreateOperation(VerifyTempFileElement element) { #if UNITY_WEBGL var operation = new VerifyTempFileWithoutThreadOperation(element); @@ -34,10 +34,10 @@ namespace YooAsset Done, } - private readonly VerifyTempElement _element; + private readonly VerifyTempFileElement _element; private ESteps _steps = ESteps.None; - public VerifyTempFileWithThreadOperation(VerifyTempElement element) + public VerifyTempFileWithThreadOperation(VerifyTempFileElement element) { _element = element; } @@ -79,13 +79,13 @@ namespace YooAsset } } - private bool BeginVerifyFileWithThread(VerifyTempElement element) + private bool BeginVerifyFileWithThread(VerifyTempFileElement element) { return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element); } private void VerifyInThread(object obj) { - VerifyTempElement element = (VerifyTempElement)obj; + VerifyTempFileElement element = (VerifyTempFileElement)obj; int result = (int)CacheSystem.VerifyingTempFile(element); element.Result = result; } @@ -103,10 +103,10 @@ namespace YooAsset Done, } - private readonly VerifyTempElement _element; + private readonly VerifyTempFileElement _element; private ESteps _steps = ESteps.None; - public VerifyTempFileWithoutThreadOperation(VerifyTempElement element) + public VerifyTempFileWithoutThreadOperation(VerifyTempFileElement element) { _element = element; } diff --git a/Assets/YooAsset/Runtime/CacheSystem/VerifyElement.cs b/Assets/YooAsset/Runtime/CacheSystem/VerifyElement.cs index ffa4ca7..fda536b 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/VerifyElement.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/VerifyElement.cs @@ -5,7 +5,7 @@ namespace YooAsset /// /// 缓存文件验证元素 /// - internal class VerifyCacheElement + internal class VerifyCacheFileElement { public string PackageName { private set; get; } public string CacheGUID { private set; get; } @@ -17,7 +17,7 @@ namespace YooAsset public string DataFileCRC; public long DataFileSize; - public VerifyCacheElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath) + public VerifyCacheFileElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath) { PackageName = packageName; CacheGUID = cacheGUID; @@ -43,7 +43,7 @@ namespace YooAsset /// /// 下载文件验证元素 /// - internal class VerifyTempElement + internal class VerifyTempFileElement { public string TempDataFilePath { private set; get; } public string FileCRC { private set; get; } @@ -51,7 +51,7 @@ namespace YooAsset public int Result = 0; // 注意:原子操作对象 - public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize) + public VerifyTempFileElement(string tempDataFilePath, string fileCRC, long fileSize) { TempDataFilePath = tempDataFilePath; FileCRC = fileCRC;