Преглед на файлове

Moved the Wait logic in the Gradient BakeImageJob to its own method for re-use

Signed-off-by: Chris Galvan <[email protected]>
Chris Galvan преди 3 години
родител
ревизия
cd7cf93054

+ 1 - 0
Gems/GradientSignal/Code/Include/GradientSignal/Editor/EditorGradientBakerComponent.h

@@ -67,6 +67,7 @@ namespace GradientSignal
 
         void Process() override;
         void CancelAndWait();
+        void Wait();
         bool IsFinished() const;
 
     private:

+ 12 - 0
Gems/GradientSignal/Code/Source/Editor/EditorGradientBakerComponent.cpp

@@ -242,12 +242,24 @@ namespace GradientSignal
         m_shouldCancel = true;
 
         // Then we synchronously block until the job has completed
+        Wait();
+    }
+
+    void BakeImageJob::Wait()
+    {
+        // Jobs don't inherently have a way to block on cancellation / completion, so we need to implement it
+        // ourselves.
+
+        // If we've already started the job, block on a condition variable that gets notified at
+        // the end of the Process() function.
         AZStd::unique_lock<decltype(m_bakeImageMutex)> lock(m_bakeImageMutex);
         if (!m_isFinished)
         {
             m_finishedNotify.wait(lock, [this] { return m_isFinished == true; });
         }
 
+        // Regardless of whether or not we were running, we need to reset the internal Job class status
+        // and clear our cancel flag.
         Reset(true);
         m_shouldCancel = false;
     }