[pypy-commit] pypy stm-thread: Remove an obvious source of conflicts.
arigo
noreply at buildbot.pypy.org
Mon May 7 16:57:32 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread
Changeset: r54936:922e53edfff5
Date: 2012-05-07 16:37 +0200
http://bitbucket.org/pypy/pypy/changeset/922e53edfff5/
Log: Remove an obvious source of conflicts.
diff --git a/pypy/module/thread/stm.py b/pypy/module/thread/stm.py
--- a/pypy/module/thread/stm.py
+++ b/pypy/module/thread/stm.py
@@ -8,6 +8,7 @@
class STMThreadLocals(OSThreadLocals):
+ can_cache = False
def initialize(self, space):
pass
diff --git a/pypy/module/thread/threadlocals.py b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -7,6 +7,8 @@
a thread finishes. This works as long as the thread was started by
os_thread.bootstrap()."""
+ can_cache = True
+
def __init__(self):
self._valuedict = {} # {thread_ident: ExecutionContext()}
self._freeze_()
@@ -14,19 +16,21 @@
def _freeze_(self):
self._valuedict.clear()
self._mainthreadident = 0
- self._mostrecentkey = 0 # fast minicaching for the common case
- self._mostrecentvalue = None # fast minicaching for the common case
+ if self.can_cache:
+ self._mostrecentkey = 0 # fast minicaching for the common case
+ self._mostrecentvalue = None # fast minicaching for the common case
return False
def getvalue(self):
ident = thread.get_ident()
- if ident == self._mostrecentkey:
+ if self.can_cache and ident == self._mostrecentkey:
result = self._mostrecentvalue
else:
value = self._valuedict.get(ident, None)
- # slow path: update the minicache
- self._mostrecentkey = ident
- self._mostrecentvalue = value
+ if self.can_cache:
+ # slow path: update the minicache
+ self._mostrecentkey = ident
+ self._mostrecentvalue = value
result = value
return result
@@ -41,9 +45,10 @@
del self._valuedict[ident]
except KeyError:
pass
- # update the minicache to prevent it from containing an outdated value
- self._mostrecentkey = ident
- self._mostrecentvalue = value
+ if self.can_cache:
+ # update the minicache to prevent it from containing an outdated value
+ self._mostrecentkey = ident
+ self._mostrecentvalue = value
def getmainthreadvalue(self):
ident = self._mainthreadident
More information about the pypy-commit
mailing list