Try to improve launch times somewhat.

This commit is contained in:
Ottermandias 2023-02-04 14:58:07 +01:00
parent 98bc14882b
commit f29bdee010
5 changed files with 147 additions and 117 deletions

View file

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Dalamud;
using Dalamud.Logging;
using Dalamud.Plugin;
@ -55,6 +57,20 @@ public abstract class DataSharer : IDisposable
}
}
protected Task<T> TryCatchDataAsync<T>(string tag, Action<T> fill) where T : class, new()
{
tag = GetVersionedTag(tag, Language, Version);
if (PluginInterface.TryGetData<T>(tag, out var data))
return Task.FromResult(data);
T ret = new();
return Task.Run(() =>
{
fill(ret);
return ret;
});
}
public static void DisposeTag(DalamudPluginInterface pi, string tag, ClientLanguage language, int version)
=> pi.RelinquishData(GetVersionedTag(tag, language, version));