Fix leftovers (#899)

This commit is contained in:
kizer 2022-06-26 02:55:05 +09:00 committed by GitHub
parent 29dee596c4
commit 3b7ec63223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 16 deletions

View file

@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -68,7 +69,14 @@ namespace Dalamud
if (!configuration.IsResumeGameAfterPluginLoad) if (!configuration.IsResumeGameAfterPluginLoad)
{ {
NativeFunctions.SetEvent(mainThreadContinueEvent); NativeFunctions.SetEvent(mainThreadContinueEvent);
_ = ServiceManager.InitializeEarlyLoadableServices(); try
{
_ = ServiceManager.InitializeEarlyLoadableServices();
}
catch (Exception e)
{
Log.Error(e, "Service initialization failure");
}
} }
else else
{ {
@ -83,20 +91,13 @@ namespace Dalamud
}; };
await Task.WhenAny(tasks); await Task.WhenAny(tasks);
foreach (var task in tasks) var faultedTasks = tasks.Where(x => x.IsFaulted).Select(x => (Exception)x.Exception!).ToArray();
{ if (faultedTasks.Any())
if (task.IsFaulted) throw new AggregateException(faultedTasks);
throw task.Exception!;
}
NativeFunctions.SetEvent(mainThreadContinueEvent); NativeFunctions.SetEvent(mainThreadContinueEvent);
await Task.WhenAll(tasks); await Task.WhenAll(tasks);
foreach (var task in tasks)
{
if (task.IsFaulted)
throw task.Exception!;
}
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -114,9 +114,9 @@ namespace Dalamud
{ {
try try
{ {
using var blockingServiceInitializeTimings = Timings.Start("BlockingServices Init");
await Task.WhenAll(blockingEarlyLoadingServices.Select(x => getAsyncTaskMap[x])); await Task.WhenAll(blockingEarlyLoadingServices.Select(x => getAsyncTaskMap[x]));
BlockingServicesLoadedTaskCompletionSource.SetResult(); BlockingServicesLoadedTaskCompletionSource.SetResult();
Timings.Event("BlockingServices Initialized");
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -52,16 +52,14 @@ namespace Dalamud
try try
{ {
var x = await ConstructObject(); var x = await ConstructObject();
if (attr?.IsAssignableTo(typeof(ServiceManager.BlockingEarlyLoadedService)) == true) ServiceManager.Log.Debug("Service<{0}>: Construction complete", typeof(T).Name);
ServiceManager.Log.Debug("Service<{0}>: Construction complete", typeof(T).Name);
InstanceTcs.SetResult(x); InstanceTcs.SetResult(x);
return x; return x;
} }
catch (Exception e) catch (Exception e)
{ {
ServiceManager.Log.Error(e, "Service<{0}>: Construction failure", typeof(T).Name);
InstanceTcs.SetException(e); InstanceTcs.SetException(e);
if (attr?.IsAssignableTo(typeof(ServiceManager.BlockingEarlyLoadedService)) == true)
ServiceManager.Log.Error(e, "Service<{0}>: Construction failure", typeof(T).Name);
throw; throw;
} }
})); }));