Skip to content

Commit

Permalink
[lit] Put display lock inside the ThreadResultsConsumer.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189553 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ddunbar committed Aug 29, 2013
1 parent ec8e059 commit b11b690
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions utils/lit/lit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,9 @@ def __init__(self, opts, numTests, progressBar=None):
self.opts = opts
self.numTests = numTests
self.current = None
self.lock = threading.Lock()
self.progressBar = progressBar
self.completed = 0

def update(self, test):
# Avoid locking overhead in quiet mode
if self.opts.quiet and not test.result.code.isFailure:
self.completed += 1
return

# Output lock.
self.lock.acquire()
try:
self.handleUpdate(test)
finally:
self.lock.release()

def finish(self):
if self.progressBar:
self.progressBar.clear()
Expand All @@ -47,13 +33,14 @@ def finish(self):
elif self.opts.succinct:
sys.stdout.write('\n')

def handleUpdate(self, test):
def update(self, test):
self.completed += 1
if self.progressBar:
self.progressBar.update(float(self.completed)/self.numTests,
test.getFullName())

if self.opts.succinct and not test.result.code.isFailure:
if not test.result.code.isFailure and \
(self.opts.quiet or self.opts.succinct):
return

if self.progressBar:
Expand Down Expand Up @@ -129,9 +116,14 @@ def runTest(self, test_index):
class ThreadResultsConsumer(object):
def __init__(self, display):
self.display = display
self.lock = threading.Lock()

def update(self, test_index, test):
self.display.update(test)
self.lock.acquire()
try:
self.display.update(test)
finally:
self.lock.release()

def taskFinished(self):
pass
Expand Down

0 comments on commit b11b690

Please sign in to comment.