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

            SemaphoreCount.Release();
        }
Exemplo 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);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 构造一个初始为给定元素的实例。
 /// </summary>
 public Semaphore(T data)
 {
     Data.AddLast(data);
     SemaphoreCount.Release(1);
 }