From: Fredrik Tolf Date: Wed, 23 Nov 2011 00:59:42 +0000 (+0100) Subject: Improved process event structure. X-Git-Tag: 0.1~11 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=709446f68b088f46f070c3e79342975a9af6b601;p=pdm.git Improved process event structure. --- 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()