mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 20:24:17 +01:00
Try to improve launch times somewhat.
This commit is contained in:
parent
98bc14882b
commit
f29bdee010
5 changed files with 147 additions and 117 deletions
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue