//public static Task<AsyncCollection<TItem>> PeekAtAny(IEnumerable<AsyncCollection<TItem>> collections, CancellationToken token) //{ // //} /// <summary> /// Peeks at a set of collections and finds the first with data available /// </summary> /// <param name="collections">An enumeration of collections to pull from</param> /// <param name="collection">Receives the collection that has an item available</param> /// <returns>True if an item is available, otherwise False</returns> public static bool TryPeekAtAny(IEnumerable <AsyncCollection <T> > collections, #if !NETSTANDARD2_0 [MaybeNullWhen(false)] #endif out AsyncCollection <T> collection) { foreach (var SourceCollection in collections) { if (SourceCollection.TryPeek()) { collection = SourceCollection; return(true); } } collection = null !; return(false); }
internal CollectionTakeResult(AsyncCollection <T> source, T item) { Source = source; Item = item; }
/// <summary> /// Attempts to take an Item from a set of collections without waiting /// </summary> /// <param name="collections">An enumeration of collections to pull from</param> /// <param name="collection">Receives the collection we took the item from</param> /// <param name="item">The item that was taken</param> /// <returns>True if we took from a collection, otherwise False</returns> public static bool TryTakeFromAny(IEnumerable <AsyncCollection <T> > collections, out AsyncCollection <T> collection, #if !NETSTANDARD2_0 [MaybeNullWhen(false)] #endif out T item) { foreach (var SourceCollection in collections) { if (SourceCollection.TryTake(out item !)) { collection = SourceCollection; return(true); } } collection = null !; item = default !;