mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
feat : 新增配置参数控制缓存文件验证最大并发数
This commit is contained in:
@@ -53,15 +53,20 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:初始化的时候缓存文件校验级别
|
||||
/// </summary>
|
||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// 自定义参数:初始化的时候缓存文件校验最大并发数
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
public int FileVerifyMaxConcurrency { private set; get; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:数据文件追加文件格式
|
||||
@@ -156,13 +161,18 @@ namespace YooAsset
|
||||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||
if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||
{
|
||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||
{
|
||||
@@ -210,8 +220,9 @@ namespace YooAsset
|
||||
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
||||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY, FileVerifyMaxConcurrency);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, CopyLocalFileServices);
|
||||
|
||||
@@ -60,15 +60,20 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public IRemoteServices RemoteServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:初始化的时候缓存文件校验级别
|
||||
/// </summary>
|
||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:覆盖安装缓存清理模式
|
||||
/// 自定义参数:初始化的时候缓存文件校验最大并发数
|
||||
/// </summary>
|
||||
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||
public int FileVerifyMaxConcurrency { private set; get; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:数据文件追加文件格式
|
||||
@@ -215,13 +220,18 @@ namespace YooAsset
|
||||
{
|
||||
RemoteServices = (IRemoteServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||
{
|
||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
|
||||
{
|
||||
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||
{
|
||||
@@ -233,11 +243,13 @@ namespace YooAsset
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
|
||||
{
|
||||
DownloadMaxConcurrency = Convert.ToInt32(value);
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
DownloadMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME)
|
||||
{
|
||||
DownloadMaxRequestPerFrame = Convert.ToInt32(value);
|
||||
int convertValue = Convert.ToInt32(value);
|
||||
DownloadMaxRequestPerFrame = Math.Clamp(convertValue, 1, int.MaxValue);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
|
||||
{
|
||||
|
||||
@@ -54,11 +54,13 @@ namespace YooAsset
|
||||
// 设置同时验证的最大数
|
||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||
int threads = Math.Min(workerThreads, ioThreads);
|
||||
_verifyMaxNum = Math.Min(threads, _fileSystem.FileVerifyMaxConcurrency);
|
||||
_verifyTotalCount = fileCount;
|
||||
if (_verifyMaxNum < 1)
|
||||
_verifyMaxNum = 1;
|
||||
|
||||
YooLogger.Log($"Verify max concurrency : {_verifyMaxNum}");
|
||||
_verifyingList = new List<VerifyFileElement>(_verifyMaxNum);
|
||||
_steps = ESteps.UpdateVerify;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace YooAsset
|
||||
public class FileSystemParametersDefine
|
||||
{
|
||||
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||
public const string FILE_VERIFY_MAX_CONCURRENCY = "FILE_VERIFY_MAX_CONCURRENCY";
|
||||
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||
|
||||
Reference in New Issue
Block a user