private void Work()
        {
#if XBOX
            int i = Interlocked.Increment(ref affinityIndex) - 1;
            int affinity = Parallel.XboxProcessorAffinity[i % Parallel.XboxProcessorAffinity.Length];
            Thread.CurrentThread.SetProcessorAffinity((int)affinity);
#endif

            Task task = new Task();
            while (true)
            {
                if (tasks.LocalPop(ref task))
                {
                    task.DoWork();
                    try { task.DoWork(); }
                    catch (Exception e) { Debug.WriteLine(e); throw; }
                }
                else
                    FindWork();
            }
        }
Exemplo n.º 2
0
        private void WorkLoop()
        {
            while (true)
            {
                resetEvent.WaitOne();
                work.DoWork();

                lock (idleWorkers)
                {
                    idleWorkers.Push(this);
                }
            }
        }
            private void WorkerLoop(object o)
            {
                Task task = new Task();

                while (true)
                {
                    if (m_scheduler.TryGetTask(out task))
                    {
                        task.DoWork();
                    }
                    else
                    {
                        HasNoWork.Set();
                        Gate.WaitOne();
                        HasNoWork.Reset();
                    }
                }
            }
Exemplo n.º 4
0
        private void Work()
        {
#if XBOX
            int i        = Interlocked.Increment(ref affinityIndex) - 1;
            int affinity = Parallel.ProcessorAffinity[i % Parallel.ProcessorAffinity.Length];
            Thread.CurrentThread.SetProcessorAffinity((int)affinity);
#endif

            Task task = new Task();
            while (true)
            {
                if (tasks.LocalPop(ref task))
                {
                    task.DoWork();
                }
                else
                {
                    FindWork();
                }
            }
        }
 private void WorkerLoop(object o)
 {
     Task task = new Task();
     while (true)
     {
         if (m_scheduler.TryGetTask(out task))
         {
             task.DoWork();
         }
         else
         {
             HasNoWork.Set();
             Gate.WaitOne();
             HasNoWork.Reset();
         }
     }
 }