swig -python -threads now generates C/C++ code which uses Python's
own threading abstraction (from pythread.h) rather than OS specific code. The old code failed to compile on MS Windows. (See SF patch tracker #1710341). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9806 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1c3fec7f2a
commit
4aaf48d650
2 changed files with 18 additions and 23 deletions
|
|
@ -1,6 +1,13 @@
|
||||||
Version 1.3.32 (in progress)
|
Version 1.3.32 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
05/12/2007: olly
|
||||||
|
[Python]
|
||||||
|
swig -python -threads now generates C/C++ code which uses Python's
|
||||||
|
own threading abstraction (from pythread.h) rather than OS specific
|
||||||
|
code. The old code failed to compile on MS Windows. (See SF patch
|
||||||
|
tracker #1710341).
|
||||||
|
|
||||||
05/04/2007: gga
|
05/04/2007: gga
|
||||||
[Ruby]
|
[Ruby]
|
||||||
Changed STL renames to be global renames. This fixes
|
Changed STL renames to be global renames. This fixes
|
||||||
|
|
|
||||||
|
|
@ -340,33 +340,21 @@ namespace Swig {
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* simple thread abstraction for pthreads on win32 */
|
|
||||||
#ifdef __THREAD__
|
#ifdef __THREAD__
|
||||||
# define __PTHREAD__
|
# include "pythread.h"
|
||||||
# if defined(_WIN32) || defined(__WIN32__)
|
class Guard
|
||||||
# define pthread_mutex_lock EnterCriticalSection
|
|
||||||
# define pthread_mutex_unlock LeaveCriticalSection
|
|
||||||
# define pthread_mutex_t CRITICAL_SECTION
|
|
||||||
# define SWIG_MUTEX_INIT(var) var
|
|
||||||
# else
|
|
||||||
# include <pthread.h>
|
|
||||||
# define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
|
||||||
struct Guard
|
|
||||||
{
|
{
|
||||||
pthread_mutex_t *_mutex;
|
PyThread_type_lock & mutex_;
|
||||||
|
|
||||||
Guard(pthread_mutex_t &mutex) : _mutex(&mutex)
|
public:
|
||||||
|
Guard(PyThread_type_lock & mutex) : mutex_(mutex)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(_mutex);
|
PyThread_acquire_lock(mutex_, WAIT_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Guard()
|
~Guard()
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(_mutex);
|
PyThread_free_lock(mutex_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
# define SWIG_GUARD(mutex) Guard _guard(mutex)
|
# define SWIG_GUARD(mutex) Guard _guard(mutex)
|
||||||
|
|
@ -437,8 +425,8 @@ namespace Swig {
|
||||||
private:
|
private:
|
||||||
typedef std::map<void*, GCItem_var> ownership_map;
|
typedef std::map<void*, GCItem_var> ownership_map;
|
||||||
mutable ownership_map owner;
|
mutable ownership_map owner;
|
||||||
#ifdef __PTHREAD__
|
#ifdef __THREAD__
|
||||||
static pthread_mutex_t swig_mutex_own;
|
static PyThread_type_lock swig_mutex_own;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -483,8 +471,8 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __PTHREAD__
|
#ifdef __THREAD__
|
||||||
pthread_mutex_t SWIG_MUTEX_INIT(Director::swig_mutex_own);
|
PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue