Esempio n. 1
0
 /// <summary>
 /// 构造一个初始为给定集合的实例。
 /// </summary>
 public Semaphore(IEnumerable <T> collection)
 {
     foreach (var data in collection)
     {
         Data.AddLast(data);
         SemaphoreCount.Release(1);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 产生一个对象。
        /// </summary>
        /// <exception cref="Exception"></exception>
        /// <returns></returns>
        public void Release(T data)
        {
            lock (Data)
            {
                Data.AddLast(data);
            }

            SemaphoreCount.Release();
        }
Esempio n. 3
0
        /// <summary>
        /// 产生一组对象。
        /// </summary>
        /// <exception cref="Exception"></exception>
        /// <returns></returns>
        public void Release(IEnumerable <T> collection)
        {
            int count = 0;

            lock (Data)
            {
                foreach (var data in collection)
                {
                    Data.AddLast(data);
                    count++;
                }
            }

            SemaphoreCount.Release(count);
        }
Esempio n. 4
0
 /// <summary>
 /// 构造一个初始为给定元素的实例。
 /// </summary>
 public Semaphore(T data)
 {
     Data.AddLast(data);
     SemaphoreCount.Release(1);
 }