Empty.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Threading;
  2. namespace Cysharp.Threading.Tasks.Linq
  3. {
  4. public static partial class UniTaskAsyncEnumerable
  5. {
  6. public static IUniTaskAsyncEnumerable<T> Empty<T>()
  7. {
  8. return Cysharp.Threading.Tasks.Linq.Empty<T>.Instance;
  9. }
  10. }
  11. internal class Empty<T> : IUniTaskAsyncEnumerable<T>
  12. {
  13. public static readonly IUniTaskAsyncEnumerable<T> Instance = new Empty<T>();
  14. Empty()
  15. {
  16. }
  17. public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
  18. {
  19. return _Empty.Instance;
  20. }
  21. class _Empty : IUniTaskAsyncEnumerator<T>
  22. {
  23. public static readonly IUniTaskAsyncEnumerator<T> Instance = new _Empty();
  24. _Empty()
  25. {
  26. }
  27. public T Current => default;
  28. public UniTask<bool> MoveNextAsync()
  29. {
  30. return CompletedTasks.False;
  31. }
  32. public UniTask DisposeAsync()
  33. {
  34. return default;
  35. }
  36. }
  37. }
  38. }