LibreOffice Module pyuno (master) 1
|
helper class for attaching the current thread to the python runtime. More...
#include <pyuno.hxx>
Public Member Functions | |
PyThreadAttach (PyInterpreterState *interp) | |
Creates a new python threadstate and acquires the global interpreter lock. More... | |
~PyThreadAttach () | |
Releases the global interpreter lock and destroys the thread state. More... | |
Private Member Functions | |
PyThreadAttach (const PyThreadAttach &)=delete | |
PyThreadAttach & | operator= (const PyThreadAttach &)=delete |
Private Attributes | |
PyThreadState * | tstate |
bool | m_isNewState |
helper class for attaching the current thread to the python runtime.
Attaching is done creating a new threadstate for the given interpreter and acquiring the global interpreter lock.
Usage:
... don't use python here { PyThreadAttach guard( PyInterpreterState_Head() ); { ... do whatever python code you want { PyThreadDetach antiguard; ... don't use python here } ... do whatever python code you want } } ... don't use python here
Note: The additional scope brackets after the PyThreadAttach are needed, e.g. when you would leave them away, dtors of potential pyrefs may be called after the thread has detached again.
|
privatedelete |
pyuno::PyThreadAttach::PyThreadAttach | ( | PyInterpreterState * | interp | ) |
Creates a new python threadstate and acquires the global interpreter lock.
precondition: The current thread MUST NOT hold the global interpreter lock. postcondition: The global interpreter lock is acquired
css::uno::RuntimeException | in case no pythread state could be created |
Definition at line 955 of file pyuno_runtime.cxx.
References m_isNewState, and tstate.
pyuno::PyThreadAttach::~PyThreadAttach | ( | ) |
Releases the global interpreter lock and destroys the thread state.
Definition at line 971 of file pyuno_runtime.cxx.
References m_isNewState, and tstate.
|
privatedelete |
|
private |
Definition at line 274 of file pyuno.hxx.
Referenced by PyThreadAttach(), and ~PyThreadAttach().
|
private |
Definition at line 273 of file pyuno.hxx.
Referenced by PyThreadAttach(), and ~PyThreadAttach().