Merge pull request #1730 from goatcorp/net8-rollup

[net8] Rollup changes from master
This commit is contained in:
KazWolfe 2024-03-19 08:17:02 -07:00 committed by GitHub
commit 9c771f4446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 44 deletions

View file

@ -146,7 +146,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
}
/// <inheritdoc/>
public Task RunOnFrameworkThreadAwaitable(Action action, CancellationToken cancellationToken = default)
public Task Run(Action action, CancellationToken cancellationToken = default)
{
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
@ -154,7 +154,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
}
/// <inheritdoc/>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<T> action, CancellationToken cancellationToken = default)
public Task<T> Run<T>(Func<T> action, CancellationToken cancellationToken = default)
{
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
@ -162,7 +162,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
}
/// <inheritdoc/>
public Task RunOnFrameworkThreadAwaitable(Func<Task> action, CancellationToken cancellationToken = default)
public Task Run(Func<Task> action, CancellationToken cancellationToken = default)
{
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
@ -170,7 +170,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
}
/// <inheritdoc/>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<Task<T>> action, CancellationToken cancellationToken = default)
public Task<T> Run<T>(Func<Task<T>> action, CancellationToken cancellationToken = default)
{
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
@ -565,20 +565,20 @@ internal class FrameworkPluginScoped : IInternalDisposableService, IFramework
this.frameworkService.DelayTicks(numTicks, cancellationToken);
/// <inheritdoc/>
public Task RunOnFrameworkThreadAwaitable(Action action, CancellationToken cancellationToken = default) =>
this.frameworkService.RunOnFrameworkThreadAwaitable(action, cancellationToken);
public Task Run(Action action, CancellationToken cancellationToken = default) =>
this.frameworkService.Run(action, cancellationToken);
/// <inheritdoc/>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<T> action, CancellationToken cancellationToken = default) =>
this.frameworkService.RunOnFrameworkThreadAwaitable(action, cancellationToken);
public Task<T> Run<T>(Func<T> action, CancellationToken cancellationToken = default) =>
this.frameworkService.Run(action, cancellationToken);
/// <inheritdoc/>
public Task RunOnFrameworkThreadAwaitable(Func<Task> action, CancellationToken cancellationToken = default) =>
this.frameworkService.RunOnFrameworkThreadAwaitable(action, cancellationToken);
public Task Run(Func<Task> action, CancellationToken cancellationToken = default) =>
this.frameworkService.Run(action, cancellationToken);
/// <inheritdoc/>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<Task<T>> action, CancellationToken cancellationToken = default) =>
this.frameworkService.RunOnFrameworkThreadAwaitable(action, cancellationToken);
public Task<T> Run<T>(Func<Task<T>> action, CancellationToken cancellationToken = default) =>
this.frameworkService.Run(action, cancellationToken);
/// <inheritdoc/>
public Task<T> RunOnFrameworkThread<T>(Func<T> func)

View file

@ -182,7 +182,7 @@ internal class TaskSchedulerWidget : IDataWindowWidget
if (ImGui.Button("Every 60f (Await)"))
{
_ = framework.RunOnFrameworkThreadAwaitable(
_ = framework.Run(
async () =>
{
for (var i = 0L; ; i++)
@ -200,7 +200,7 @@ internal class TaskSchedulerWidget : IDataWindowWidget
if (ImGui.Button("Every 1s (Await)"))
{
_ = framework.RunOnFrameworkThreadAwaitable(
_ = framework.Run(
async () =>
{
for (var i = 0L; ; i++)
@ -241,7 +241,7 @@ internal class TaskSchedulerWidget : IDataWindowWidget
if (ImGui.Button("Freeze Completely"))
{
_ = framework.RunOnFrameworkThreadAwaitable(() => Helper().Wait());
_ = framework.Run(() => Helper().Wait());
static async Task Helper() => await Task.Delay(1000);
}

View file

@ -9,18 +9,18 @@ namespace Dalamud.Plugin.Services;
/// This class represents the Framework of the native game client and grants access to various subsystems.
/// </summary>
/// <remarks>
/// <para><b>Choosing between <c>RunOnFrameworkThread</c> and <c>RunOnFrameworkThreadAwaitable</c></b></para>
/// <para><b>Choosing between <c>RunOnFrameworkThread</c> and <c>Run</c></b></para>
/// <ul>
/// <li>If you do need to do use <c>await</c> and have your task keep executing on the main thread after waiting is
/// done, use <c>RunOnFrameworkThreadAwaitable</c>.</li>
/// done, use <c>Run</c>.</li>
/// <li>If you need to call <see cref="Task.Wait()"/> or <see cref="Task{TResult}.Result"/>, use
/// <c>RunOnFrameworkThread</c>.</li>
/// <c>RunOnFrameworkThread</c>. It also skips the task scheduler if invoked already from the framework thread.</li>
/// </ul>
/// <para>The game is likely to completely lock up if you call above synchronous function and getter, because starting
/// a new task by default runs on <see cref="TaskScheduler.Current"/>, which would make the task run on the framework
/// thread if invoked via <c>RunOnFrameworkThreadAwaitable</c>. This includes <c>Task.Factory.StartNew</c> and
/// thread if invoked via <c>Run</c>. This includes <c>Task.Factory.StartNew</c> and
/// <c>Task.ContinueWith</c>. Use <c>Task.Run</c> if you need to start a new task from the callback specified to
/// <c>RunOnFrameworkThreadAwaitable</c>, as it will force your task to be run in the default thread pool.</para>
/// <c>Run</c>, as it will force your task to be run in the default thread pool.</para>
/// <para>See <see cref="TaskSchedulerWidget"/> to see the difference in behaviors, and how would a misuse of these
/// functions result in a deadlock.</para>
/// </remarks>
@ -85,10 +85,10 @@ public interface IFramework
/// <para>Starting new tasks and waiting on them <b>synchronously</b> from this callback will completely lock up
/// the game. Use <c>await</c> if you need to wait on something from an <c>async</c> callback.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task RunOnFrameworkThreadAwaitable(Action action, CancellationToken cancellationToken = default);
public Task Run(Action action, CancellationToken cancellationToken = default);
/// <summary>
/// Run given function right away if this function has been called from game's Framework.Update thread, or otherwise run on next Framework.Update call.
@ -101,10 +101,10 @@ public interface IFramework
/// <para>Starting new tasks and waiting on them <b>synchronously</b> from this callback will completely lock up
/// the game. Use <c>await</c> if you need to wait on something from an <c>async</c> callback.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<T> action, CancellationToken cancellationToken = default);
public Task<T> Run<T>(Func<T> action, CancellationToken cancellationToken = default);
/// <summary>
/// Run given function right away if this function has been called from game's Framework.Update thread, or otherwise run on next Framework.Update call.
@ -116,10 +116,10 @@ public interface IFramework
/// <para>Starting new tasks and waiting on them <b>synchronously</b> from this callback will completely lock up
/// the game. Use <c>await</c> if you need to wait on something from an <c>async</c> callback.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task RunOnFrameworkThreadAwaitable(Func<Task> action, CancellationToken cancellationToken = default);
public Task Run(Func<Task> action, CancellationToken cancellationToken = default);
/// <summary>
/// Run given function right away if this function has been called from game's Framework.Update thread, or otherwise run on next Framework.Update call.
@ -132,10 +132,10 @@ public interface IFramework
/// <para>Starting new tasks and waiting on them <b>synchronously</b> from this callback will completely lock up
/// the game. Use <c>await</c> if you need to wait on something from an <c>async</c> callback.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task<T> RunOnFrameworkThreadAwaitable<T>(Func<Task<T>> action, CancellationToken cancellationToken = default);
public Task<T> Run<T>(Func<Task<T>> action, CancellationToken cancellationToken = default);
/// <summary>
/// Run given function right away if this function has been called from game's Framework.Update thread, or otherwise run on next Framework.Update call.
@ -146,11 +146,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task<T> RunOnFrameworkThread<T>(Func<T> func);
@ -163,11 +163,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task RunOnFrameworkThread(Action action);
@ -181,11 +181,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
[Obsolete($"Use {nameof(RunOnTick)} instead.")]
@ -199,11 +199,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
[Obsolete($"Use {nameof(RunOnTick)} instead.")]
@ -221,11 +221,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task<T> RunOnTick<T>(Func<T> func, TimeSpan delay = default, int delayTicks = default, CancellationToken cancellationToken = default);
@ -241,11 +241,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task RunOnTick(Action action, TimeSpan delay = default, int delayTicks = default, CancellationToken cancellationToken = default);
@ -262,11 +262,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task<T> RunOnTick<T>(Func<Task<T>> func, TimeSpan delay = default, int delayTicks = default, CancellationToken cancellationToken = default);
@ -282,11 +282,11 @@ public interface IFramework
/// <remarks>
/// <para><c>await</c>, <c>Task.Factory.StartNew</c> or alike will continue off the framework thread.</para>
/// <para>Awaiting on the returned <see cref="Task"/> from <c>RunOnFrameworkThread</c>,
/// <c>RunOnFrameworkThreadAwaitable</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// <c>Run</c>, or <c>RunOnTick</c> right away inside the callback specified to this
/// function has a chance of locking up the game. Do not do <c>await framework.RunOnFrameworkThread(...);</c>
/// directly or indirectly from the delegate passed to this function.</para>
/// <para>See the remarks on <see cref="IFramework"/> if you need to choose which one to use, between
/// <c>RunOnFrameworkThreadAwaitable</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// <c>Run</c> and <c>RunOnFrameworkThread</c>. Note that <c>RunOnTick</c> is a fancy
/// version of <c>RunOnFrameworkThread</c>.</para>
/// </remarks>
public Task RunOnTick(Func<Task> func, TimeSpan delay = default, int delayTicks = default, CancellationToken cancellationToken = default);