[pypy-commit] pypy stm-gc: Re-add rstm.thread_id().
arigo
noreply at buildbot.pypy.org
Mon Apr 23 10:28:01 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54643:308b4d036534
Date: 2012-04-23 09:24 +0200
http://bitbucket.org/pypy/pypy/changeset/308b4d036534/
Log: Re-add rstm.thread_id().
diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -11,6 +11,8 @@
NUM_THREADS_DEFAULT = 4 # XXX for now
+MAIN_THREAD_ID = 0
+
class TransactionError(Exception):
pass
@@ -34,6 +36,9 @@
def in_transaction():
return bool(stm_operations().in_transaction())
+def thread_id():
+ return stm_operations().thread_id()
+
def run_all_transactions(initial_transaction,
num_threads = NUM_THREADS_DEFAULT):
diff --git a/pypy/translator/stm/test/targetdemo.py b/pypy/translator/stm/test/targetdemo.py
--- a/pypy/translator/stm/test/targetdemo.py
+++ b/pypy/translator/stm/test/targetdemo.py
@@ -81,6 +81,7 @@
class InitialTransaction(rstm.Transaction):
def run(self):
ll_assert(self.retry_counter == 0, "no reason to abort-and-retry here")
+ ll_assert(rstm.thread_id() != 0, "thread_id == 0")
scheduled = []
for i in range(glob.NUM_THREADS):
arg = Arg()
@@ -99,6 +100,7 @@
glob.LENGTH = int(argv[2])
if len(argv) > 3:
glob.USE_MEMORY = bool(int(argv[3]))
+ ll_assert(rstm.thread_id() == 0, "thread_id != 0")
#
rstm.run_all_transactions(InitialTransaction(),
num_threads=glob.NUM_THREADS)
diff --git a/pypy/translator/stm/test/test_ztranslated.py b/pypy/translator/stm/test/test_ztranslated.py
--- a/pypy/translator/stm/test/test_ztranslated.py
+++ b/pypy/translator/stm/test/test_ztranslated.py
@@ -6,7 +6,7 @@
class TestSTMTranslated(CompiledSTMTests):
- def test_hello_world(self):
+ def test_targetdemo(self):
t, cbuilder = self.compile(targetdemo.entry_point)
data, dataerr = cbuilder.cmdexec('4 5000', err=True)
assert 'check ok!' in data
More information about the pypy-commit
mailing list