mirror of https://github.com/Cysharp/UniTask
ValueTask is available in Unity 2021_2_OR_NEWER or .NET Core
parent
81f2e37ea5
commit
fbbba061dd
|
@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks
|
|||
|
||||
// similar as IValueTaskSource
|
||||
public interface IUniTaskSource
|
||||
#if !NETSTANDARD2_0
|
||||
#if (!UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
|
||||
: System.Threading.Tasks.Sources.IValueTaskSource
|
||||
#pragma warning disable CS0108
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ namespace Cysharp.Threading.Tasks
|
|||
|
||||
UniTaskStatus UnsafeGetStatus(); // only for debug use.
|
||||
|
||||
#if !NETSTANDARD2_0
|
||||
#if (!UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
|
||||
#pragma warning restore CS0108
|
||||
|
||||
System.Threading.Tasks.Sources.ValueTaskSourceStatus System.Threading.Tasks.Sources.IValueTaskSource.GetStatus(short token)
|
||||
|
@ -53,13 +53,13 @@ namespace Cysharp.Threading.Tasks
|
|||
}
|
||||
|
||||
public interface IUniTaskSource<out T> : IUniTaskSource
|
||||
#if !NETSTANDARD2_0
|
||||
#if (!UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
|
||||
, System.Threading.Tasks.Sources.IValueTaskSource<T>
|
||||
#endif
|
||||
{
|
||||
new T GetResult(short token);
|
||||
|
||||
#if !NETSTANDARD2_0
|
||||
#if (!UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
|
||||
|
||||
new public UniTaskStatus GetStatus(short token)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma warning disable 0649
|
||||
#if !UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER
|
||||
#pragma warning disable 0649
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -95,3 +96,4 @@ namespace Cysharp.Threading.Tasks
|
|||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -69,6 +69,8 @@ namespace Cysharp.Threading.Tasks
|
|||
return new UniTask<bool>(new IsCanceledSource(source), token);
|
||||
}
|
||||
|
||||
#if !UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER
|
||||
|
||||
public static implicit operator System.Threading.Tasks.ValueTask(in UniTask self)
|
||||
{
|
||||
if (self.source == null)
|
||||
|
@ -83,6 +85,8 @@ namespace Cysharp.Threading.Tasks
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (source == null) return "()";
|
||||
|
@ -436,6 +440,8 @@ namespace Cysharp.Threading.Tasks
|
|||
return self.AsUniTask();
|
||||
}
|
||||
|
||||
#if !UNITY_2018_1_OR_NEWER || UNITY_2021_2_OR_NEWER
|
||||
|
||||
public static implicit operator System.Threading.Tasks.ValueTask<T>(in UniTask<T> self)
|
||||
{
|
||||
if (self.source == null)
|
||||
|
@ -450,6 +456,8 @@ namespace Cysharp.Threading.Tasks
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// returns (bool IsCanceled, T Result) instead of throws OperationCanceledException.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue