// Token: 0x060022E9 RID: 8937 RVA: 0x00196570 File Offset: 0x00194770 private bool ProcessRegularUpdates(bool force) { while (this.graphUpdateQueueRegular.Count > 0) { GraphUpdateProcessor.GUOSingle guosingle = this.graphUpdateQueueRegular.Peek(); GraphUpdateThreading graphUpdateThreading = (guosingle.order == GraphUpdateProcessor.GraphUpdateOrder.FloodFill) ? GraphUpdateThreading.SeparateThread : guosingle.graph.CanUpdateAsync(guosingle.obj); if (force || !Application.isPlaying || this.graphUpdateThread == null || !this.graphUpdateThread.IsAlive) { graphUpdateThreading &= (GraphUpdateThreading)(-2); } if ((graphUpdateThreading & GraphUpdateThreading.UnityInit) != GraphUpdateThreading.UnityThread) { if (this.StartAsyncUpdatesIfQueued()) { return(false); } guosingle.graph.UpdateAreaInit(guosingle.obj); } if ((graphUpdateThreading & GraphUpdateThreading.SeparateThread) != GraphUpdateThreading.UnityThread) { this.graphUpdateQueueRegular.Dequeue(); this.graphUpdateQueueAsync.Enqueue(guosingle); if ((graphUpdateThreading & GraphUpdateThreading.UnityPost) != GraphUpdateThreading.UnityThread && this.StartAsyncUpdatesIfQueued()) { return(false); } } else { if (this.StartAsyncUpdatesIfQueued()) { return(false); } this.graphUpdateQueueRegular.Dequeue(); if (guosingle.order == GraphUpdateProcessor.GraphUpdateOrder.FloodFill) { this.FloodFill(); } else { try { guosingle.graph.UpdateArea(guosingle.obj); } catch (Exception arg) { Debug.LogError("Error while updating graphs\n" + arg); } } if ((graphUpdateThreading & GraphUpdateThreading.UnityPost) != GraphUpdateThreading.UnityThread) { guosingle.graph.UpdateAreaPost(guosingle.obj); } } } return(!this.StartAsyncUpdatesIfQueued()); }
void ProcessPostUpdates() { while (graphUpdateQueuePost.Count > 0) { GUOSingle s = graphUpdateQueuePost.Dequeue(); GraphUpdateThreading threading = s.graph.CanUpdateAsync(s.obj); if ((threading & GraphUpdateThreading.UnityPost) != 0) { try { s.graph.UpdateAreaPost(s.obj); } catch (System.Exception e) { Debug.LogError("Error while updating graphs (post step)\n" + e); } } } }
private void ProcessPostUpdates() { while (this.graphUpdateQueuePost.Count > 0) { GraphUpdateProcessor.GUOSingle guosingle = this.graphUpdateQueuePost.Dequeue(); GraphUpdateThreading graphUpdateThreading = guosingle.graph.CanUpdateAsync(guosingle.obj); if ((graphUpdateThreading & GraphUpdateThreading.UnityPost) != GraphUpdateThreading.UnityThread) { try { guosingle.graph.UpdateAreaPost(guosingle.obj); } catch (Exception arg) { Debug.LogError("Error while updating graphs (post step)\n" + arg); } } } }
private bool ProcessRegularUpdates(bool force) { while (graphUpdateQueueRegular.Count > 0) { GUOSingle s = graphUpdateQueueRegular.Peek(); GraphUpdateThreading threading = s.graph.CanUpdateAsync(s.obj); #if UNITY_WEBGL // Never use multithreading in WebGL threading &= ~GraphUpdateThreading.SeparateThread; #else // When not playing or when not using a graph update thread (or if it has crashed), everything runs in the Unity thread if (force || !Application.isPlaying || graphUpdateThread == null || !graphUpdateThread.IsAlive) { // Remove the SeparateThread flag threading &= ~GraphUpdateThreading.SeparateThread; } #endif if ((threading & GraphUpdateThreading.UnityInit) != 0) { // Process async graph updates first. // Next call to this function will process this object so it is not dequeued now if (StartAsyncUpdatesIfQueued()) { return(false); } s.graph.UpdateAreaInit(s.obj); } if ((threading & GraphUpdateThreading.SeparateThread) != 0) { // Move GUO to async queue to be updated by another thread graphUpdateQueueRegular.Dequeue(); graphUpdateQueueAsync.Enqueue(s); // Don't start any more async graph updates because this update // requires a Unity thread function to run after it has been completed // but before the next update is started if ((threading & GraphUpdateThreading.UnityPost) != 0) { if (StartAsyncUpdatesIfQueued()) { return(false); } } } else { // Unity Thread if (StartAsyncUpdatesIfQueued()) { return(false); } graphUpdateQueueRegular.Dequeue(); try { s.graph.UpdateArea(s.obj); } catch (System.Exception e) { Debug.LogError("Error while updating graphs\n" + e); } if ((threading & GraphUpdateThreading.UnityPost) != 0) { s.graph.UpdateAreaPost(s.obj); } } } if (StartAsyncUpdatesIfQueued()) { return(false); } return(true); }
/** Updates graphs. * Will do some graph updates, possibly signal another thread to do them. * Will only process graph updates added by QueueGraphUpdatesInternal * * \param force If true, all graph updates will be processed before this function returns. The return value * will be True. * * \returns True if all graph updates have been done and pathfinding (or other tasks) may resume. * False if there are still graph updates being done or waiting in the queue. * * */ bool ProcessGraphUpdates(bool force) { if (force) { asyncGraphUpdatesComplete.WaitOne(); } else { #if !UNITY_WEBGL if (!asyncGraphUpdatesComplete.WaitOne(0)) { return(false); } #endif } if (graphUpdateQueueAsync.Count != 0) { throw new System.Exception("Queue should be empty at this stage"); } while (graphUpdateQueueRegular.Count > 0) { GUOSingle s = graphUpdateQueueRegular.Peek(); GraphUpdateThreading threading = s.order == GraphUpdateOrder.FloodFill ? GraphUpdateThreading.SeparateThread : s.graph.CanUpdateAsync(s.obj); #if !UNITY_WEBGL bool forceUnityThread = force; // When not playing or when not using a graph update thread (or if it has crashed), everything runs in the Unity thread if (!Application.isPlaying || graphUpdateThread == null || !graphUpdateThread.IsAlive) { forceUnityThread = true; } if (!forceUnityThread && (threading == GraphUpdateThreading.SeparateAndUnityInit)) { if (graphUpdateQueueAsync.Count > 0) { //Process async graph updates first. //Next call to this function will process this object so it is not dequeued now asyncGraphUpdatesComplete.Reset(); graphUpdateAsyncEvent.Set(); return(false); } s.graph.UpdateAreaInit(s.obj); //Move GUO to async queue to be updated by another thread graphUpdateQueueRegular.Dequeue(); graphUpdateQueueAsync.Enqueue(s); //Next call to this function will process this object so it is not dequeued now asyncGraphUpdatesComplete.Reset(); graphUpdateAsyncEvent.Set(); return(false); } else if (!forceUnityThread && (threading == GraphUpdateThreading.SeparateThread)) { //Move GUO to async queue to be updated by another thread graphUpdateQueueRegular.Dequeue(); graphUpdateQueueAsync.Enqueue(s); } else { #endif //Everything should be done in the unity thread if (graphUpdateQueueAsync.Count > 0) { //Process async graph updates first. if (force) { throw new System.Exception("This should not happen"); } //Next call to this function will process this object so it is not dequeued now asyncGraphUpdatesComplete.Reset(); graphUpdateAsyncEvent.Set(); return(false); } graphUpdateQueueRegular.Dequeue(); if (s.order == GraphUpdateOrder.FloodFill) { FloodFill(); } else { if (threading == GraphUpdateThreading.SeparateAndUnityInit) { try { s.graph.UpdateAreaInit(s.obj); } catch (System.Exception e) { Debug.LogError("Error while initializing GraphUpdates\n" + e); } } try { s.graph.UpdateArea(s.obj); } catch (System.Exception e) { Debug.LogError("Error while updating graphs\n" + e); } } #if !UNITY_WEBGL } #endif } #if !UNITY_WEBGL if (graphUpdateQueueAsync.Count > 0) { //Next call to this function will process this object so it is not dequeued now asyncGraphUpdatesComplete.Reset(); graphUpdateAsyncEvent.Set(); return(false); } #endif GraphModifier.TriggerEvent(GraphModifier.EventType.PostUpdate); if (OnGraphsUpdated != null) { OnGraphsUpdated(); } return(true); }