UniVRM/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/ImmediateCaller.cs
Takayuki Matsuoka a68d0122ce BREAKING CHANGE: Introduce NextFrameIfTimedOut as a new interface method of IAwaitCaller
This is a breaking change since it introduces new interface method to IAwaitCaller.

----

NextFrameIfTimedOut() is added to IAwaitCaller.  The following inheritors also introduce the method.

- ImmediateCaller.NextFrameIfTimedOut() just invokes NextFrame().
- RuntimeOnlyAwaitCaller.NextFrameIfTimedOut() invokes NextFrame() if timed out.  Otherwise, do nothing.
- RuntimeOnlyNoThreadAwaitCaller.NextFrameIfTimedOut() works same as RuntimeOnlyAwaitCaller.

Constructor of RuntimeOnlyAwaitCaller and RuntimeOnlyNoThreadAwaitCaller
now take argument of timeout in seconds.  The default value is 1/1000 (1 milliseconds).

See also:
https://github.com/vrm-c/UniVRM/pull/1781#pullrequestreview-1100131840
2022-09-08 17:39:05 +09:00

29 lines
603 B
C#

using System;
using System.Threading.Tasks;
namespace VRMShaders
{
/// <summary>
/// 同期実行
/// </summary>
public sealed class ImmediateCaller : IAwaitCaller
{
public Task NextFrame()
{
return Task.FromResult<object>(null);
}
public Task Run(Action action)
{
action();
return Task.FromResult<object>(null);
}
public Task<T> Run<T>(Func<T> action)
{
return Task.FromResult(action());
}
public Task NextFrameIfTimedOut() => NextFrame();
}
}