mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ABatchProcessor nullable. ConfigureProcessor removed
This commit is contained in:
parent
5377cd0cce
commit
6572f14f49
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed;
|
||||
using Wabbajack.VirtualFileSystem;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -15,9 +16,9 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
public WorkQueue Queue { get; } = new WorkQueue();
|
||||
|
||||
public Context VFS { get; private set; }
|
||||
public Context VFS { get; }
|
||||
|
||||
protected StatusUpdateTracker UpdateTracker { get; private set; }
|
||||
protected StatusUpdateTracker UpdateTracker { get; }
|
||||
|
||||
private Subject<Percent> _percentCompleted { get; } = new Subject<Percent>();
|
||||
|
||||
@ -42,7 +43,6 @@ namespace Wabbajack.Lib
|
||||
private Subject<bool> _isRunning { get; } = new Subject<bool>();
|
||||
public IObservable<bool> IsRunning => _isRunning;
|
||||
|
||||
private int _configured;
|
||||
private int _started;
|
||||
private readonly CancellationTokenSource _cancel = new CancellationTokenSource();
|
||||
|
||||
@ -53,21 +53,16 @@ namespace Wabbajack.Lib
|
||||
public BehaviorSubject<byte> MaxCores = new BehaviorSubject<byte>(byte.MaxValue);
|
||||
public BehaviorSubject<Percent> TargetUsagePercent = new BehaviorSubject<Percent>(Percent.One);
|
||||
|
||||
protected void ConfigureProcessor(int steps, IObservable<int> numThreads = null)
|
||||
public ABatchProcessor(int steps)
|
||||
{
|
||||
if (1 == Interlocked.CompareExchange(ref _configured, 1, 1))
|
||||
{
|
||||
throw new InvalidDataException("Can't configure a processor twice");
|
||||
}
|
||||
Queue.SetActiveThreadsObservable(numThreads);
|
||||
UpdateTracker = new StatusUpdateTracker(steps);
|
||||
VFS = new Context(Queue) { UpdateTracker = UpdateTracker };
|
||||
Queue.Status.Subscribe(_queueStatus)
|
||||
.DisposeWith(_subs);
|
||||
Queue.LogMessages.Subscribe(_logMessages)
|
||||
.DisposeWith(_subs);
|
||||
UpdateTracker.Progress.Subscribe(_percentCompleted);
|
||||
UpdateTracker.StepName.Subscribe(_textStatus);
|
||||
VFS = new Context(Queue) { UpdateTracker = UpdateTracker };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
@ -50,6 +50,11 @@ namespace Wabbajack.Lib
|
||||
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
|
||||
public Dictionary<Hash, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<Hash, IEnumerable<VirtualFile>>();
|
||||
|
||||
public ACompiler(int steps)
|
||||
: base(steps)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Info(string msg)
|
||||
{
|
||||
Utils.Log(msg);
|
||||
|
@ -31,7 +31,8 @@ namespace Wabbajack.Lib
|
||||
|
||||
public SystemParameters SystemParameters { get; set; }
|
||||
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters)
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters, int steps)
|
||||
: base(steps)
|
||||
{
|
||||
ModList = modList;
|
||||
ModListArchive = archive;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ namespace Wabbajack.Lib
|
||||
$"vfs_compile_cache-{Path.Combine((string)MO2Folder ?? "Unknown", "ModOrganizer.exe").StringSha256Hex()}.bin");
|
||||
|
||||
public MO2Compiler(AbsolutePath mo2Folder, string mo2Profile, AbsolutePath outputFile)
|
||||
: base(steps: 20)
|
||||
{
|
||||
MO2Folder = mo2Folder;
|
||||
MO2Profile = mo2Profile;
|
||||
@ -88,7 +89,7 @@ namespace Wabbajack.Lib
|
||||
protected override async Task<bool> _Begin(CancellationToken cancel)
|
||||
{
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
ConfigureProcessor(20, ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
Queue.SetActiveThreadsObservable(ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
UpdateTracker.Reset();
|
||||
UpdateTracker.NextStep("Gathering information");
|
||||
Info("Looking for other profiles");
|
||||
|
@ -38,7 +38,8 @@ namespace Wabbajack.Lib
|
||||
modList: modList,
|
||||
outputFolder: outputFolder,
|
||||
downloadFolder: downloadFolder,
|
||||
parameters: parameters)
|
||||
parameters: parameters,
|
||||
steps: 20)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ namespace Wabbajack.Lib
|
||||
var metric = Metrics.Send(Metrics.BeginInstall, ModList.Name);
|
||||
Utils.Log("Configuring Processor");
|
||||
|
||||
ConfigureProcessor(20, ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
Queue.SetActiveThreadsObservable(ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
var game = ModList.GameType.MetaData();
|
||||
|
||||
if (GameFolder == null)
|
||||
|
@ -26,7 +26,8 @@ namespace Wabbajack.Lib
|
||||
modList: modList,
|
||||
outputFolder: outputFolder,
|
||||
downloadFolder: downloadFolder,
|
||||
parameters: parameters)
|
||||
parameters: parameters,
|
||||
steps: 10)
|
||||
{
|
||||
#if DEBUG
|
||||
// TODO: only for testing
|
||||
@ -51,7 +52,7 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
ConfigureProcessor(10, ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
Queue.SetActiveThreadsObservable(ConstructDynamicNumThreads(await RecommendQueueSize()));
|
||||
DownloadFolder.CreateDirectory();
|
||||
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
|
@ -532,7 +532,6 @@ namespace Wabbajack.Test
|
||||
return state.ToJson().FromJsonString<T>();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task TestUpgrading()
|
||||
{
|
||||
@ -553,13 +552,12 @@ namespace Wabbajack.Test
|
||||
Assert.Equal(Hash.FromBase64("gCRVrvzDNH0="), await dest.FileHashCachedAsync());
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TestInstaller : AInstaller
|
||||
{
|
||||
public TestInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters) : base(archive, modList, outputFolder, downloadFolder, parameters)
|
||||
public TestInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters)
|
||||
: base(archive, modList, outputFolder, downloadFolder, parameters, steps: 1)
|
||||
{
|
||||
ConfigureProcessor(1, new Subject<int>().StartWith(1));
|
||||
Queue.SetActiveThreadsObservable(Observable.Return(1));
|
||||
}
|
||||
|
||||
protected override Task<bool> _Begin(CancellationToken cancel)
|
||||
@ -569,10 +567,5 @@ namespace Wabbajack.Test
|
||||
|
||||
public override ModManager ModManager { get => ModManager.MO2; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
Loading…
Reference in New Issue
Block a user