diff mercurial/streamclone.py @ 52923:f1ac5117459b

stream-clone-v2: avoid waking further thread if only 1 item is available Letting the thread waiting for something it can use seems more reasonable.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 Feb 2025 23:28:09 +0100
parents 0af8965b668a
children 119cddd02b8c
line wrap: on
line diff
--- a/mercurial/streamclone.py	Wed Feb 05 12:17:00 2025 +0100
+++ b/mercurial/streamclone.py	Mon Feb 03 23:28:09 2025 +0100
@@ -1259,7 +1259,10 @@
                 # grab the lock to look at a possible available value
                 self._lock.acquire()
                 # disarm the lock if necessary.
-                if self._wait.locked():
+                #
+                # If the queue only constains one item, keep the _wait lock
+                # armed, as there is no need to wake another waiter anyway.
+                if self._wait.locked() and len(self._queue) > 1:
                     self._wait.release()
             return self._queue.popleft()