Пример #1
0
        public static void LoadData()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyVoxelPrecalc.LoadData");

            MyMwcLog.WriteLine("MyVoxelPrecalc.LoadData() - START");
            MyMwcLog.IncreaseIndent();

            //  For calculating on main thread
            m_singleCoreTask = new MyVoxelPrecalcTask();

            Tasks = new ConcurrentQueue <MyVoxelPrecalcTaskItem>();
            if (MyMinerGame.NumberOfCores > 1)
            {
                m_tasks       = new Task[MyMinerGame.NumberOfCores];
                m_precalWorks = new MyVoxelPrecalcWork[MyMinerGame.NumberOfCores];

                for (int i = 0; i < MyMinerGame.NumberOfCores; i++)
                {
                    m_precalWorks[i] = new MyVoxelPrecalcWork();
                }
            }

            /*
             * //  For calculating in parallel threads
             * if (MyMinerGame.NumberOfCores > MyConstants.ONE_CORE)
             * {
             *  Locker = new object();
             *  m_threads = new Thread[MyMinerGame.NumberOfCores];
             *  m_workToDo = new AutoResetEvent[MyMinerGame.NumberOfCores];
             *  m_workIsDone = new AutoResetEvent[MyMinerGame.NumberOfCores];
             *  for (int i = 0; i < MyMinerGame.NumberOfCores; i++)
             *  {
             *      //  Signal events for each thread
             *      m_workToDo[i] = new AutoResetEvent(false);
             *      m_workIsDone[i] = new AutoResetEvent(false);
             *
             *      //  Thread
             *      MyVoxelPrecalcThread precalcThread = new MyVoxelPrecalcThread(m_workToDo[i], m_workIsDone[i]);
             *      m_threads[i] = new Thread(new ThreadStart(precalcThread.Run));
             *      m_threads[i].Name = "MyVoxelPrecalcTask " + i.ToString();
             *      m_threads[i].IsBackground = true;
             *      m_threads[i].Start();
             *  }
             * }     */

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyVoxelPrecalc.LoadData() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
Пример #2
0
        public static void LoadData()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyVoxelPrecalc.LoadData");

            MyMwcLog.WriteLine("MyVoxelPrecalc.LoadData() - START");
            MyMwcLog.IncreaseIndent();

            //  For calculating on main thread
            m_singleCoreTask = new MyVoxelPrecalcTask();

            Tasks = new ConcurrentQueue<MyVoxelPrecalcTaskItem>();
            if (MyMinerGame.NumberOfCores > 1)
            {
                m_tasks = new Task[MyMinerGame.NumberOfCores];
                m_precalWorks = new MyVoxelPrecalcWork[MyMinerGame.NumberOfCores];

                for (int i = 0; i < MyMinerGame.NumberOfCores; i++)
                    m_precalWorks[i] = new MyVoxelPrecalcWork();
            }
       
            /*
            //  For calculating in parallel threads
            if (MyMinerGame.NumberOfCores > MyConstants.ONE_CORE)
            {
                Locker = new object();
                m_threads = new Thread[MyMinerGame.NumberOfCores];
                m_workToDo = new AutoResetEvent[MyMinerGame.NumberOfCores];
                m_workIsDone = new AutoResetEvent[MyMinerGame.NumberOfCores];
                for (int i = 0; i < MyMinerGame.NumberOfCores; i++)
                {
                    //  Signal events for each thread
                    m_workToDo[i] = new AutoResetEvent(false);
                    m_workIsDone[i] = new AutoResetEvent(false);

                    //  Thread
                    MyVoxelPrecalcThread precalcThread = new MyVoxelPrecalcThread(m_workToDo[i], m_workIsDone[i]);
                    m_threads[i] = new Thread(new ThreadStart(precalcThread.Run));
                    m_threads[i].Name = "MyVoxelPrecalcTask " + i.ToString();
                    m_threads[i].IsBackground = true;
                    m_threads[i].Start();
                }
            }     */

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyVoxelPrecalc.LoadData() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }