aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-01-04 18:48:25 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:52 -0300
commitb2c20708545f7992f337c3be4c8595f7fb848a07 (patch)
treea76ad3f6a2fab0f6e97860ee15b837985cf01cf7
parent05f8c6272fec133e64ca0d23a1622d9c086b02b2 (diff)
Release the gil for every C++ function call, ignoring allow-thread attribute on typesystem.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index b560d6aea..18e9d0b22 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -1710,8 +1710,6 @@ void CppGenerator::writeFunctionCalls(QTextStream& s, const OverloadData& overlo
s << INDENT << "{" << endl;
{
Indentation indent(INDENT);
- if (overloadData.hasAllowThread())
- s << INDENT << "Shiboken::ThreadStateSaver " THREAD_STATE_SAVER_VAR ";" << endl;
s << INDENT << (overloads.count() > 1 ? "switch (overloadId) " : "") << '{' << endl;
{
@@ -1905,9 +1903,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
// Used to provide contextual information to custom code writer function.
const AbstractMetaArgument* lastArg = 0;
- if (func->allowThread())
- s << INDENT << THREAD_STATE_SAVER_VAR ".save();" << endl;
-
CodeSnipList snips;
if (func->hasInjectedCode()) {
snips = func->injectedCodeSnips();
@@ -1934,9 +1929,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
if (convRules.size())
writeCodeSnips(s, convRules, CodeSnip::Beginning, TypeSystem::TargetLangCode, func);
- // Code to restore the threadSaver has been written?
- bool threadRestored = false;
-
if (!func->isUserAdded()) {
bool badModifications = false;
QStringList userArgs;
@@ -2110,7 +2102,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
if (!injectedCodeCallsCppFunction(func)) {
- s << INDENT;
+ s << INDENT << "PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS" << endl << INDENT;
if (isCtor) {
s << "cptr = ";
} else if (func->type() && !func->isInplaceOperator()) {
@@ -2131,11 +2123,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
s << " " CPP_RETURN_VAR " = ";
}
s << methodCall << ';' << endl;
-
- if (func->allowThread()) {
- s << INDENT << THREAD_STATE_SAVER_VAR ".restore();" << endl;
- threadRestored = true;
- }
+ s << INDENT << "PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS" << endl;
if (!isCtor && !func->isInplaceOperator() && func->type()) {
s << INDENT << PYTHON_RETURN_VAR " = ";
@@ -2145,9 +2133,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
}
- if (!threadRestored && func->allowThread())
- s << INDENT << THREAD_STATE_SAVER_VAR ".restore();" << endl;
-
if (func->hasInjectedCode() && !func->isConstructor()) {
s << endl;
writeCodeSnips(s, snips, CodeSnip::End, TypeSystem::TargetLangCode, func, lastArg);