Thread safety patch for Python STL iterators from Abhinandan Jain

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10317 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-03-21 23:11:24 +00:00
commit a1100e9964
2 changed files with 13 additions and 5 deletions

View file

@ -6,7 +6,7 @@
*
* Implement a python 'output' iterator for Python 2.2 or higher.
*
* Users can derive form the PySwigIterator to implemet their
* Users can derive form the PySwigIterator to implement their
* own iterators. As an example (real one since we use it for STL/STD
* containers), the template PySwigIterator_T does the
* implementation for genereic C++ iterators.
@ -57,17 +57,22 @@ namespace swig {
// C++ common/needed methods
virtual PySwigIterator *copy() const = 0;
PyObject *next()
PyObject *next()
{
SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
PyObject *obj = value();
incr();
return obj;
incr();
SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
return obj;
}
PyObject *previous()
{
SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
decr();
return value();
PyObject *obj = value();
SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
return obj;
}
PySwigIterator *advance(ptrdiff_t n)