[pypy-commit] pypy stm: A poor man's lock: just use a regular counter and check it every second.

arigo noreply at buildbot.pypy.org
Thu Nov 3 11:41:04 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48690:65545adde075
Date: 2011-11-03 11:40 +0100
http://bitbucket.org/pypy/pypy/changeset/65545adde075/

Log:	A poor man's lock: just use a regular counter and check it every
	second. As it's all protected by STM it works nicely.

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
@@ -30,6 +30,7 @@
         add_at_end_of_chained_list(glob.anchor, i)
         rstm.transaction_boundary()
     print "thread done."
+    glob.done += 1
 
 
 
@@ -55,10 +56,12 @@
 def entry_point(argv):
     invoke_around_extcall(before_external_call, after_external_call)
     print "hello world"
+    glob.done = 0
     for i in range(NUM_THREADS):
         ll_thread.start_new_thread(run_me, ())
     print "sleeping..."
-    time.sleep(10)
+    while glob.done < NUM_THREADS:    # poor man's lock
+        time.sleep(1)
     print "done sleeping."
     return 0
 


More information about the pypy-commit mailing list