Commits

rimmington  committed 0fd7d67 Draft

added Consumer enumerable to Channel

  • Participants
  • Parent commits 6833feb

Comments (0)

Files changed (1)

File Cineraria.Concurrency/Channel.cs

 // -----------------------------------------------------------------------
 namespace Cineraria.Concurrency
 {
+    using System;
+    using System.Collections;
     using System.Collections.Generic;
     using ThreadInterruptedException = System.Threading.ThreadInterruptedException;
 
         }
 
         /// <summary>
+        /// Gets an <see cref="IEnumerable"/> that calls <see cref="Take"/>
+        /// to get each new item and so has an effectively infinite length.
+        /// </summary>
+        public IEnumerable<T> Consumer
+        {
+            get
+            {
+                while (true)
+                {
+                    yield return this.Take();
+                }
+            }
+        }
+
+        /// <summary>
         /// Puts the specified item into the channel.
         /// </summary>
         /// <param name="item">The item.</param>