[pypy-commit] pypy stmgc-c7: add is_atomic to atomic.py and transaction.py
Raemi
noreply at buildbot.pypy.org
Tue Aug 19 13:16:24 CEST 2014
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: stmgc-c7
Changeset: r72904:0e51cd5f2023
Date: 2014-08-19 13:16 +0200
http://bitbucket.org/pypy/pypy/changeset/0e51cd5f2023/
Log: add is_atomic to atomic.py and transaction.py
diff --git a/lib_pypy/atomic.py b/lib_pypy/atomic.py
--- a/lib_pypy/atomic.py
+++ b/lib_pypy/atomic.py
@@ -5,7 +5,8 @@
try:
from __pypy__ import thread as _thread
- from __pypy__.thread import atomic, getsegmentlimit, hint_commit_soon
+ from __pypy__.thread import (atomic, getsegmentlimit,
+ hint_commit_soon, is_atomic)
except ImportError:
# Not a STM-enabled PyPy. We can still provide a version of 'atomic'
# that is good enough for our purposes. With this limited version,
@@ -22,6 +23,10 @@
def hint_commit_soon():
pass
+ def is_atomic():
+ return atomic.locked()
+
+
else:
import re, sys, linecache
diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py
--- a/lib_pypy/transaction.py
+++ b/lib_pypy/transaction.py
@@ -15,13 +15,15 @@
import sys, thread, collections, cStringIO, linecache
try:
- from __pypy__.thread import atomic
+ from __pypy__.thread import atomic, is_atomic
except ImportError:
# Not a STM-enabled PyPy. We can use a regular lock for 'atomic',
# which is good enough for our purposes. With this limited version,
# an atomic block in thread X will not prevent running thread Y, if
# thread Y is not within an atomic block at all.
atomic = thread.allocate_lock()
+ def is_atomic():
+ return atomic.locked()
try:
from __pypy__.thread import signals_enabled
More information about the pypy-commit
mailing list