[pypy-commit] pypy stm-gc: Add 'transaction.local' in the emulator too. (This is a complete
arigo
noreply at buildbot.pypy.org
Fri Apr 20 13:38:34 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54574:48347aefd009
Date: 2012-04-20 13:23 +0200
http://bitbucket.org/pypy/pypy/changeset/48347aefd009/
Log: Add 'transaction.local' in the emulator too. (This is a complete
implementation.)
diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py
--- a/lib_pypy/transaction.py
+++ b/lib_pypy/transaction.py
@@ -106,3 +106,17 @@
finally:
_in_transaction = False
pending.clear() # this is the behavior we get with interp_transaction
+
+
+class local(object):
+ """Thread-local data. Behaves like a regular object, but its content
+ is not shared between multiple concurrently-running transactions.
+ It can be accessed without conflicts.
+
+ It can be used for purely transaction-local data.
+
+ It can also be used for long-living caches that store values that
+ are (1) not too costly to compute and (2) not too memory-hungry,
+ because they will end up being computed and stored once per actual
+ thread.
+ """
More information about the pypy-commit
mailing list