Release the jwack token when doing a synchronous lock wait.

Although we were deadlock-free before, under some circumstances we'd end up
holding a perfectly good token while in sync wait; that would reduce our
parallelism for no good reason.  So give back our tokens before waiting for
anybody else.
This commit is contained in:
Avery Pennarun 2010-12-10 23:04:46 -08:00
commit c4be0050f7
2 changed files with 19 additions and 1 deletions

View file

@ -24,6 +24,13 @@ def _release(n):
_mytokens = 1
def release_mine():
global _mytokens
assert(_mytokens >= 1)
os.write(_fds[1], 't')
_mytokens -= 1
def _timeout(sig, frame):
pass
@ -161,9 +168,12 @@ def running():
def wait_all():
_debug("wait_all\n")
while running():
while _mytokens >= 1:
release_mine()
_debug("wait_all: wait()\n")
wait(want_token=0)
_debug("wait_all: empty list\n")
get_token('self') # get my token back
if _toplevel:
bb = ''
while 1: