diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-01-04 18:48:25 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-01-04 19:27:09 -0200 |
commit | 786da143a916a81d11ba7bc4f14af71f6893584c (patch) | |
tree | 726e31044fe16db3323231b1848ce88ee53b649b | |
parent | 7ed5767ccfe005aaddfc2e5032dac2966154d87c (diff) | |
download | shiboken-786da143a916a81d11ba7bc4f14af71f6893584c.tar.gz shiboken-786da143a916a81d11ba7bc4f14af71f6893584c.tar.xz shiboken-786da143a916a81d11ba7bc4f14af71f6893584c.zip |
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.cpp | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 1c9c90fa..9d8fb79f 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; @@ -2108,7 +2100,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()) { @@ -2129,11 +2121,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 " = "; @@ -2143,9 +2131,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); |