From 709446f68b088f46f070c3e79342975a9af6b601 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 23 Nov 2011 01:59:42 +0100 Subject: [PATCH 1/1] Improved process event structure. --- pdm/perf.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pdm/perf.py b/pdm/perf.py index de2dba5..34db2ea 100644 --- a/pdm/perf.py +++ b/pdm/perf.py @@ -100,21 +100,32 @@ class event(object): idlock = threading.Lock() procevid = 0 -class startevent(event): + +def getprocid(): + global procevid + idlock.acquire() + try: + ret = procevid + procevid += 1 + return ret + finally: + idlock.release() + +class procevent(event): + def __init__(self, id): + super(procevent, self).__init__() + if isinstance(id, procevent): + self.id = id.id + else: + self.id = id + +class startevent(procevent): def __init__(self): - super(startevent, self).__init__() - global procevid - idlock.acquire() - try: - self.id = procevid - procevid += 1 - finally: - idlock.release() - -class finishevent(event): + super(startevent, self).__init__(getprocid()) + +class finishevent(procevent): def __init__(self, start, aborted): - super(finishevent, self).__init__() - self.id = start.id + super(finishevent, self).__init__(start) self.aborted = aborted sysres = staticdir() -- 2.11.0