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(); }
public MyVoxelPrecalcWork() { m_task = new MyVoxelPrecalcTask(); }
public static void UnloadData() { /* // If there are running threads, we need to abort them, otherwise application will still live if (MyMinerGame.NumberOfCores > MyConstants.ONE_CORE) { if (m_threads != null) { for (int i = 0; i < m_threads.Length; i++) { if (m_threads[i] != null) { // Abort won't stop the thread immediately (it just throws exception inside it), so we use Join to wait until that thread is really finished m_threads[i].Abort(); m_threads[i].Join(); } } } } */ m_precalWorks = null; m_singleCoreTask = null; }