mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Init TEngine4.0.0
Init TEngine4.0.0
This commit is contained in:
54
UnityProject/Packages/UniTask/Runtime/Linq/Throw.cs
Normal file
54
UnityProject/Packages/UniTask/Runtime/Linq/Throw.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Cysharp.Threading.Tasks.Internal;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Cysharp.Threading.Tasks.Linq
|
||||
{
|
||||
public static partial class UniTaskAsyncEnumerable
|
||||
{
|
||||
public static IUniTaskAsyncEnumerable<TValue> Throw<TValue>(Exception exception)
|
||||
{
|
||||
return new Throw<TValue>(exception);
|
||||
}
|
||||
}
|
||||
|
||||
internal class Throw<TValue> : IUniTaskAsyncEnumerable<TValue>
|
||||
{
|
||||
readonly Exception exception;
|
||||
|
||||
public Throw(Exception exception)
|
||||
{
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public IUniTaskAsyncEnumerator<TValue> GetAsyncEnumerator(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return new _Throw(exception, cancellationToken);
|
||||
}
|
||||
|
||||
class _Throw : IUniTaskAsyncEnumerator<TValue>
|
||||
{
|
||||
readonly Exception exception;
|
||||
CancellationToken cancellationToken;
|
||||
|
||||
public _Throw(Exception exception, CancellationToken cancellationToken)
|
||||
{
|
||||
this.exception = exception;
|
||||
this.cancellationToken = cancellationToken;
|
||||
}
|
||||
|
||||
public TValue Current => default;
|
||||
|
||||
public UniTask<bool> MoveNextAsync()
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return UniTask.FromException<bool>(exception);
|
||||
}
|
||||
|
||||
public UniTask DisposeAsync()
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user