Commit 4fcd6f8f authored by Jason Madden's avatar Jason Madden

Make the non-reentrancy threadlocal. sadly that slows semaphore down to 0.5usec

parent 111affcc
......@@ -26,20 +26,31 @@ if PYPY:
def __init__(self):
self._owner = None
self._block = _allocate_lock()
self._locking = 0
self._locking = {}
self._count = 0
def untraceable(f):
# Don't allow re-entry to these functions, as can
# Don't allow re-entry to these functions in a single thread, as can
# happen if a sys.settrace is used
def wrapper(self):
if self._locking:
me = _get_ident()
try:
count = self._locking[me]
except KeyError:
count = self._locking[me] = 1
else:
count = self._locking[me] = count + 1
if count:
return
try:
self._locking += 1
return f(self)
finally:
self._locking -= 1
count = count - 1
if not count:
del self._locking[me]
else:
self._locking[me] = count
return wrapper
@untraceable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment