Add BuildFontsAsync for parallel font/theme init
This commit is contained in:
@@ -100,6 +100,19 @@ public class FontManager
|
|||||||
JpRange = BuildRange(GlyphRangesJapanese.GlyphRanges);
|
JpRange = BuildRange(GlyphRangesJapanese.GlyphRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Async wrapper around <see cref="BuildFonts"/> for the Phase-1 LoadAsync
|
||||||
|
/// path. The font-atlas build is CPU-bound, so we offload via Task.Run and
|
||||||
|
/// honour the cancellation token at the scheduling boundary; this lets the
|
||||||
|
/// font build run in parallel with the theme init without blocking the
|
||||||
|
/// loader. Settings-driven manual rebuilds keep using the sync entry point.
|
||||||
|
/// </summary>
|
||||||
|
public async Task BuildFontsAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
await Task.Run(BuildFonts, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
public void BuildFonts()
|
public void BuildFonts()
|
||||||
{
|
{
|
||||||
SetUpRanges();
|
SetUpRanges();
|
||||||
|
|||||||
@@ -490,11 +490,10 @@ public sealed class Plugin : IAsyncDalamudPlugin
|
|||||||
// Group A: Font + Theme parallel — both CPU-bound, independent, and
|
// Group A: Font + Theme parallel — both CPU-bound, independent, and
|
||||||
// dominate the load-time profile. Everything else stays sequential to
|
// dominate the load-time profile. Everything else stays sequential to
|
||||||
// keep ordering simple.
|
// keep ordering simple.
|
||||||
var fontTask = Task.Run(() =>
|
var fontTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
FontManager = new FontManager();
|
FontManager = new FontManager();
|
||||||
// TODO(v1.4.x): replace with FontManager.BuildFontsAsync(cancellationToken)
|
await FontManager.BuildFontsAsync(cancellationToken).ConfigureAwait(false);
|
||||||
FontManager.BuildFonts();
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
var themeTask = Task.Run(() =>
|
var themeTask = Task.Run(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user