mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-14 22:50:08 -05:00
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
29 lines
603 B
C#
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();
|
|
}
|
|
} |