Esempio n. 1
0
        /// <summary>
        /// Read from the channel set in a probing manner
        /// </summary>
        /// <param name="self">The channels to read from</param>
        /// <param name="channel">The channel written to</param>
        /// <param name="value">The value to write into the channel</param>
        /// <typeparam name="T">The channel data type parameter.</typeparam>
        public static bool TryWriteToAny <T>(this MultiChannelSetWrite <T> self, T value, out IWriteChannel <T> channel)
        {
            var res = self.WriteToAnyAsync(value, Timeout.Immediate).WaitForTask();

            if (res.IsFaulted || res.IsCanceled)
            {
                channel = res.Result;
                return(true);
            }
            else
            {
                channel = null;
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Write to the channel set in a blocking manner
        /// </summary>
        /// <param name="self">The channels to read from</param>
        /// <param name="timeout">The maximum time to wait for a slot</param>
        /// <param name="value">The value to write into the channel</param>
        /// <typeparam name="T">The channel data type parameter.</typeparam>
        public static IWriteChannel <T> WriteToAny <T>(this MultiChannelSetWrite <T> self, T value, TimeSpan timeout)
        {
            try
            {
                return(self.WriteToAnyAsync(value, timeout).WaitForTask().Result);
            }
            catch (AggregateException aex)
            {
                if (aex.Flatten().InnerExceptions.Count == 1)
                {
                    throw aex.InnerException;
                }

                throw;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Invokes the retire method on all channels in the set
 /// </summary>
 /// <param name="self">The channels to retire</param>
 /// <param name="immediate">A value indicating if the retire is performed immediately.</param>
 /// <typeparam name="T">The channel data type parameter.</typeparam>
 public static void Retire <T>(this MultiChannelSetWrite <T> self, bool immediate = false)
 {
     self.RetireAsync(immediate).WaitForTaskOrThrow();
 }
Esempio n. 4
0
        /// <summary>
        /// Read from the channel set in a probing manner
        /// </summary>
        /// <param name="self">The channels to read from</param>
        /// <param name="value">The value to write into the channel</param>
        /// <typeparam name="T">The channel data type parameter.</typeparam>
        public static bool TryWriteToAny <T>(this MultiChannelSetWrite <T> self, T value)
        {
            IWriteChannel <T> dummy;

            return(TryWriteToAny(self, value, out dummy));
        }
Esempio n. 5
0
 /// <summary>
 /// Write to the channel set in a blocking manner
 /// </summary>
 /// <param name="self">The channels to read from</param>
 /// <param name="value">The value to write into the channel</param>
 /// <typeparam name="T">The channel data type parameter.</typeparam>
 public static IWriteChannel <T> WriteToAny <T>(this MultiChannelSetWrite <T> self, T value)
 {
     return(WriteToAny(self, value, Timeout.Infinite));
 }