/// <summary> /// Executes all task callbacks for the thread calling this function. /// It is thread safe. /// </summary> public static void RunCallbacks() { CallbackBuffer.ApplyChanges(); for (int i = 0; i < CallbackBuffer.Count; ++i) { WorkItem item = CallbackBuffer[i]; Debug.Assert(item != null); if (item == null) { continue; } if (item.Callback != null) { item.Callback(); item.Callback = null; } if (item.DataCallback != null) { item.DataCallback(item.WorkData); item.DataCallback = null; } item.WorkData = null; item.Requeue(); } CallbackBuffer.ClearList(); }
public override void Draw() { base.Draw(); if (MySession.Static == null) { m_list.ClearList(); } m_list.ApplyChanges(); Text("Queried Out Areas: {0}", m_list.Count); foreach (var info in m_list) { MyRenderProxy.DebugDrawOBB(info.Bounds, Color.Cyan, .2f, true, true); //MyRenderProxy.DebugDrawText3D(info.Bounds.Center, string.Format("{0}: {1}", info.Body.StorageName, info.Id), Color.Cyan, .8f, true); } }
//WorkPriority IPrioritizedWork.Priority //{ // get { return WorkPriority.VeryLow; } //} void IWork.DoWork(WorkData workData) { MySimpleProfiler.Begin("MyDepositQuery.DoWork"); try { m_result.ClearList(); m_emptyCells = new List <Vector3I>(); var cache = Cache; cache.Resize(new Vector3I(MyOreDetectorComponent.CELL_SIZE_IN_LOD_VOXELS)); var storage = VoxelMap.Storage as IMyStorage; if (storage == null || storage.Closed) { return; } Vector3I c; for (c.Z = Min.Z; c.Z <= Max.Z; ++c.Z) { for (c.Y = Min.Y; c.Y <= Max.Y; ++c.Y) { for (c.X = Min.X; c.X <= Max.X; ++c.X) { if (storage == null || storage.Closed) { break; } ProcessCell(cache, storage, c); } } } m_result.ApplyChanges(); } finally { MySimpleProfiler.End(); } }