Author: Armin Rigo <[email protected]>
Branch:
Changeset: r256:be0306e43d45
Date: 2014-05-03 13:46 +0200
http://bitbucket.org/pypy/benchmarks/changeset/be0306e43d45/
Log: Update to use the new 'atomic' module
diff --git a/multithread/common/abstract_threading.py
b/multithread/common/abstract_threading.py
--- a/multithread/common/abstract_threading.py
+++ b/multithread/common/abstract_threading.py
@@ -2,12 +2,7 @@
from threading import Thread, Condition, Lock, local
import thread, atexit, sys, time
-try:
- from __pypy__.thread import atomic, getsegmentlimit
-except ImportError:
- atomic = Lock()
- def getsegmentlimit():
- return 1
+from atomic import atomic, getsegmentlimit, print_abort_info
class TLQueue_concurrent(object):
diff --git a/multithread/threadworms/threadworms.py
b/multithread/threadworms/threadworms.py
--- a/multithread/threadworms/threadworms.py
+++ b/multithread/threadworms/threadworms.py
@@ -6,7 +6,7 @@
# This is meant to be an educational example of multithreaded programming,
# so I get kind of verbose in the comments.
-from common.abstract_threading import atomic, Future
+from common.abstract_threading import atomic, Future, print_abort_info
import time
import random, sys, threading
@@ -61,6 +61,7 @@
self.direction = self.rnd.choice((UP, DOWN, LEFT, RIGHT))
with atomic:
+ print_abort_info(0.01)
# GRID_LOCK.acquire() # don't return (that is, block) until
this thread can acquire the lock
nextx, nexty = self.getNextPosition()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit