[pypy-commit] pypy stm-gc: main_thread_id is zero after all.

arigo noreply at buildbot.pypy.org
Sat Feb 11 16:30:45 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52374:9ba7bb9d0e0a
Date: 2012-02-11 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/9ba7bb9d0e0a/

Log:	main_thread_id is zero after all.

diff --git a/pypy/module/transaction/interp_transaction.py b/pypy/module/transaction/interp_transaction.py
--- a/pypy/module/transaction/interp_transaction.py
+++ b/pypy/module/transaction/interp_transaction.py
@@ -8,6 +8,8 @@
 
 NUM_THREADS_DEFAULT = 4     # by default
 
+MAIN_THREAD_ID = 0
+
 
 class State(object):
 
@@ -21,7 +23,6 @@
         self.ll_no_tasks_pending_lock = threadintf.null_ll_lock
         self.ll_unfinished_lock = threadintf.null_ll_lock
         self.threadobjs = {}      # empty during translation
-        self.main_thread_id = 0
         self.pending = Fifo()
 
     def _freeze_(self):
@@ -69,15 +70,11 @@
 
     def setvalue(self, value):
         id = rstm.thread_id()
-        if self.main_thread_id == 0:
-            self.main_thread_id = id
-        else:
-            # this should not be used from a transaction
-            assert id == self.main_thread_id
+        assert id == MAIN_THREAD_ID   # should not be used from a transaction
         self.threadobjs[id] = value
 
     def getmainthreadvalue(self):
-        return self.threadobjs.get(self.main_thread_id, None)
+        return self.threadobjs.get(MAIN_THREAD_ID, None)
 
     def getallvalues(self):
         return self.threadobjs
@@ -267,7 +264,7 @@
             state.w_error,
             space.wrap("recursive invocation of transaction.run()"))
     state.startup_run()
-    assert state.main_thread_id == rstm.thread_id()
+    assert rstm.thread_id() == MAIN_THREAD_ID
     assert not state.is_locked_no_tasks_pending()
     if state.pending.is_empty():
         return
@@ -292,7 +289,7 @@
     #
     assert state.num_waiting_threads == 0
     assert state.pending.is_empty()
-    assert state.threadobjs.keys() == [state.main_thread_id]
+    assert state.threadobjs.keys() == [MAIN_THREAD_ID]
     assert not state.is_locked_no_tasks_pending()
     state.running = False
     #


More information about the pypy-commit mailing list