Skip to content

Commit

Permalink
Merge pull request #533 from doyasu24/feature/add-unitask-asvaluetask…
Browse files Browse the repository at this point in the history
…-for-unity

add UniTask.AsValueTask for Unity
  • Loading branch information
neuecc authored Jan 24, 2024
2 parents 66de0d3 + 4fe0861 commit 6cd0026
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/IUniTaskSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public enum UniTaskStatus

// similar as IValueTaskSource
public interface IUniTaskSource
#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if (!UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
: System.Threading.Tasks.Sources.IValueTaskSource
#pragma warning disable CS0108
#endif
Expand All @@ -30,7 +30,7 @@ public interface IUniTaskSource

UniTaskStatus UnsafeGetStatus(); // only for debug use.

#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if (!UNITY_2018_3_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)
Expand All @@ -53,13 +53,13 @@ void System.Threading.Tasks.Sources.IValueTaskSource.OnCompleted(Action<object>
}

public interface IUniTaskSource<out T> : IUniTaskSource
#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if (!UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0
, System.Threading.Tasks.Sources.IValueTaskSource<T>
#endif
{
new T GetResult(short token);

#if !UNITY_2018_3_OR_NEWER && !NETSTANDARD2_0
#if (!UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER) && !NETSTANDARD2_0

new public UniTaskStatus GetStatus(short token)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable 0649
#if !UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER
#pragma warning disable 0649

using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -95,3 +96,4 @@ public void OnCompleted(Action<object> continuation, object state, short token,
#endif
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public UniTask<bool> SuppressCancellationThrow()
return new UniTask<bool>(new IsCanceledSource(source), token);
}

#if !UNITY_2018_3_OR_NEWER
#if !UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER

public static implicit operator System.Threading.Tasks.ValueTask(in UniTask self)
{
Expand Down Expand Up @@ -440,7 +440,7 @@ public static implicit operator UniTask(UniTask<T> self)
return self.AsUniTask();
}

#if !UNITY_2018_3_OR_NEWER
#if !UNITY_2018_3_OR_NEWER || UNITY_2021_2_OR_NEWER

public static implicit operator System.Threading.Tasks.ValueTask<T>(in UniTask<T> self)
{
Expand Down

0 comments on commit 6cd0026

Please sign in to comment.