add UniTask.AsValueTask for Unity

pull/533/head
doyasu24 2024-01-19 00:29:21 +09:00
parent 66de0d3a58
commit 81f2e37ea5
No known key found for this signature in database
4 changed files with 15 additions and 12 deletions

View File

@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks
// similar as IValueTaskSource
public interface IUniTaskSource
#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if !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 !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if !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 !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if !NETSTANDARD2_0
, System.Threading.Tasks.Sources.IValueTaskSource<T>
#endif
{
new T GetResult(short token);
#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if !NETSTANDARD2_0
new public UniTaskStatus GetStatus(short token)
{

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d38f0478933be42d895c37b862540a1c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -69,8 +69,6 @@ namespace Cysharp.Threading.Tasks
return new UniTask<bool>(new IsCanceledSource(source), token);
}
#if !UNITY_2018_3_OR_NEWER
public static implicit operator System.Threading.Tasks.ValueTask(in UniTask self)
{
if (self.source == null)
@ -85,8 +83,6 @@ namespace Cysharp.Threading.Tasks
#endif
}
#endif
public override string ToString()
{
if (source == null) return "()";
@ -440,8 +436,6 @@ namespace Cysharp.Threading.Tasks
return self.AsUniTask();
}
#if !UNITY_2018_3_OR_NEWER
public static implicit operator System.Threading.Tasks.ValueTask<T>(in UniTask<T> self)
{
if (self.source == null)
@ -456,8 +450,6 @@ namespace Cysharp.Threading.Tasks
#endif
}
#endif
/// <summary>
/// returns (bool IsCanceled, T Result) instead of throws OperationCanceledException.
/// </summary>