Ticket #364: python.i-diff-against-reformatted-original.patch
File python.i-diff-against-reformatted-original.patch, 1.6 KB (added by , 13 years ago) |
---|
-
(a) reformatted-python.i.orig vs. (b) python.i
a b 28 28 * overhead of thread locking when the user's code isn't using threads. */ 29 29 #define SWIG_PYTHON_NO_USE_GIL 30 30 31 static __thread PyThreadState * swig_pythreadstate = NULL; 32 31 33 class XapianSWIG_Python_Thread_Block { 32 34 bool status; 33 PyGILState_STATE state;34 35 public: 35 36 XapianSWIG_Python_Thread_Block() 36 : status(PyEval_ThreadsInitialized() ) {37 : status(PyEval_ThreadsInitialized() && swig_pythreadstate) { 37 38 if (status) { 38 state = PyGILState_Ensure(); 39 PyEval_RestoreThread(swig_pythreadstate); 40 swig_pythreadstate = NULL; 39 41 } 40 42 } 41 43 void end() { 42 44 if (status) { 43 PyGILState_Release(state); 45 if (swig_pythreadstate) Py_FatalError("swig_pythreadstate set in XapianSWIG_Python_Thread_Block::end()"); 46 swig_pythreadstate = PyEval_SaveThread(); 44 47 status = false; 45 48 } 46 49 } … … 49 52 50 53 class XapianSWIG_Python_Thread_Allow { 51 54 bool status; 52 PyThreadState *save;53 55 public: 54 56 XapianSWIG_Python_Thread_Allow() : status(PyEval_ThreadsInitialized()) { 55 57 if (status) { 56 save = PyEval_SaveThread(); 58 if (swig_pythreadstate) Py_FatalError("swig_pythreadstate set in XapianSWIG_Python_Thread_Allow ctor"); 59 swig_pythreadstate = PyEval_SaveThread(); 57 60 } 58 61 } 59 62 void end() { 60 63 if (status) { 61 PyEval_RestoreThread(save); 64 if (!swig_pythreadstate) Py_FatalError("swig_pythreadstate unset in XapianSWIG_Python_Thread_Block::end()"); 65 PyEval_RestoreThread(swig_pythreadstate); 66 swig_pythreadstate = NULL; 62 67 status = false; 63 68 } 64 69 }