Dolda2000 GitWeb
/
pdm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
87b07b3
)
Improved process event structure.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 23 Nov 2011 00:59:42 +0000
(
01:59
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 23 Nov 2011 00:59:42 +0000
(
01:59
+0100)
pdm/perf.py
patch
|
blob
|
blame
|
history
diff --git
a/pdm/perf.py
b/pdm/perf.py
index
de2dba5
..
34db2ea
100644
(file)
--- a/
pdm/perf.py
+++ b/
pdm/perf.py
@@
-100,21
+100,32
@@
class event(object):
idlock = threading.Lock()
procevid = 0
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):
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):
def __init__(self, start, aborted):
- super(finishevent, self).__init__()
- self.id = start.id
+ super(finishevent, self).__init__(start)
self.aborted = aborted
sysres = staticdir()
self.aborted = aborted
sysres = staticdir()