Exemple #1
0
        /// <summary>
        ///		构造函数, 创建一个线程安全,顺序返回0..n-1的循环计数器
        /// </summary>
        /// <param name="n">上限</param>
        public LoopCounter(int n)
        {
            if (n > 10000)
            {
                throw new NotSupportedException("Only support n <= 10000");
            }
            if (n == 0)
            {
                throw new NotSupportedException("Bad parameter n == 0");
            }

            //
            //
            _n    = n;
            _mask = NumberUtils.NextPower2(n * 40000) - 1;
            _i    = 0;
        }