1
0

PromiseHelper.cs 772 B

1234567891011121314151617181920212223242526
  1. #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
  2. #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. namespace UniRx.InternalUtil
  7. {
  8. internal static class PromiseHelper
  9. {
  10. internal static void TrySetResultAll<T>(IEnumerable<TaskCompletionSource<T>> source, T value)
  11. {
  12. var rentArray = source.ToArray(); // better to use Arraypool.
  13. var array = rentArray;
  14. var len = rentArray.Length;
  15. for (int i = 0; i < len; i++)
  16. {
  17. array[i].TrySetResult(value);
  18. array[i] = null;
  19. }
  20. }
  21. }
  22. }
  23. #endif