15 #include "pythonThread.h" 28 PythonThread(PyObject *
function, PyObject *args,
29 const string &name,
const string &sync_name) :
37 if (!PyCallable_Check(_function)) {
38 nassert_raise(
"Invalid function passed to PythonThread constructor");
41 if (args == Py_None) {
43 _args = PyTuple_New(0);
46 if (PySequence_Check(args)) {
47 _args = PySequence_Tuple(args);
50 nassert_raise(
"Invalid args passed to PythonThread constructor");
54 #ifndef SIMPLE_THREADS 56 #ifdef WITH_THREAD // This symbol defined within Python.h 71 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) 72 PyGILState_STATE gstate;
73 gstate = PyGILState_Ensure();
80 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) 81 PyGILState_Release(gstate);
95 PyObject *PythonThread::
99 if (_result == NULL) {
101 return Py_BuildValue(
"");
115 _result = call_python_func(_function, _args);
118 #endif // HAVE_PYTHON void join()
Blocks the calling process until the thread terminates.
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.