Ejemplo n.º 1
0
        public void SpinOnce()
        {
            ntime += 1;

            if (isSingleCpu)
            {
                // On a single-CPU system, spinning does no good
                ThreadEx.Yield();
            }
            else
            {
                if (ntime % step == 0)
                {
                    ThreadEx.Yield();
                }
                else
                {
                    // Multi-CPU system might be hyper-threaded, let other thread run
                    Thread.SpinWait(Math.Min(ntime, maxTime) << 1);
                }
            }
        }