ultrahdr: signal all threads that no further jobs will be queued

After queuing all jobs, the master thread quietly leaves without
intimating the worker threads about the same. If worker threads are
waiting for more jobs, they will be waiting forever or until a
spurious wake occurs. Instead of waiting for spurious wake, signal
all workers that no more jobs will be queued

Bug: 279984162
Test: CTS: ImageReaderTest#testSRGBJpeg
(cherry picked from https://partner-android-review.googlesource.com/q/commit:db2a72623137e59cae7d9a74b0ba4ebc3f7ee36a)
Merged-In: Ic0e06b8ee355b08f0cd1031488cbf0ead8021fa2
Change-Id: Ic0e06b8ee355b08f0cd1031488cbf0ead8021fa2
diff --git a/libs/ultrahdr/jpegr.cpp b/libs/ultrahdr/jpegr.cpp
index 0f7aa27..ef927e3 100644
--- a/libs/ultrahdr/jpegr.cpp
+++ b/libs/ultrahdr/jpegr.cpp
@@ -534,7 +534,7 @@
       if (mQueuedAllJobs) {
         return false;
       } else {
-        mCv.wait(lock);
+        mCv.wait_for(lock, std::chrono::milliseconds(100));
       }
     } else {
       auto it = mJobs.begin();
@@ -557,6 +557,8 @@
 void JobQueue::markQueueForEnd() {
   std::unique_lock<std::mutex> lock{mMutex};
   mQueuedAllJobs = true;
+  lock.unlock();
+  mCv.notify_all();
 }
 
 void JobQueue::reset() {