[pypy-commit] pypy default: put DummyLock in rthread
bdkearns
noreply at buildbot.pypy.org
Fri May 2 00:06:39 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r71156:c494afbfef83
Date: 2014-05-01 17:27 -0400
http://bitbucket.org/pypy/pypy/changeset/c494afbfef83/
Log: put DummyLock in rthread
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -692,23 +692,17 @@
def allocate_lock(self):
"""Return an interp-level Lock object if threads are enabled,
and a dummy object if they are not."""
- if self.config.objspace.usemodules.thread:
- # we use a sub-function to avoid putting the 'import' statement
- # here, where the flow space would see it even if thread=False
- return self.__allocate_lock()
- else:
- return dummy_lock
-
- def __allocate_lock(self):
- from rpython.rlib.rthread import allocate_lock, error
+ from rpython.rlib import rthread
+ if not self.config.objspace.usemodules.thread:
+ return rthread.dummy_lock
# hack: we can't have prebuilt locks if we're translating.
# In this special situation we should just not lock at all
# (translation is not multithreaded anyway).
if not we_are_translated() and self.config.translating:
raise CannotHaveLock()
try:
- return allocate_lock()
- except error:
+ return rthread.allocate_lock()
+ except rthread.error:
raise OperationError(self.w_RuntimeError,
self.wrap("out of resources"))
@@ -1722,24 +1716,6 @@
return space.getitem(w_glob, space.wrap('anonymous'))
-class DummyLock(object):
- def acquire(self, flag):
- return True
-
- def release(self):
- pass
-
- def _freeze_(self):
- return True
-
- def __enter__(self):
- pass
-
- def __exit__(self, *args):
- pass
-
-dummy_lock = DummyLock()
-
# Table describing the regular part of the interface of object spaces,
# namely all methods which only take w_ arguments and return a w_ result
# (if any).
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -1,4 +1,3 @@
-
from rpython.rtyper.lltypesystem import rffi, lltype, llmemory
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.conftest import cdir
@@ -113,6 +112,24 @@
assert len(y) == 0
return rffi.cast(lltype.Signed, ll_start_new_thread(x))
+class DummyLock(object):
+ def acquire(self, flag):
+ return True
+
+ def release(self):
+ pass
+
+ def _freeze_(self):
+ return True
+
+ def __enter__(self):
+ pass
+
+ def __exit__(self, *args):
+ pass
+
+dummy_lock = DummyLock()
+
class Lock(object):
""" Container for low-level implementation
of a lock object
More information about the pypy-commit
mailing list