Ticket #137: pythreads.patch
File pythreads.patch, 1.6 KB (added by , 18 years ago) |
---|
-
.cc
old new 2808 2808 # endif 2809 2809 #endif 2810 2810 2811 /* simple thread abstraction for pthreads on win32 */2812 2811 #ifdef __THREAD__ 2813 # define __PTHREAD__ 2814 # if defined(_WIN32) || defined(__WIN32__) 2815 # define pthread_mutex_lock EnterCriticalSection 2816 # define pthread_mutex_unlock LeaveCriticalSection 2817 # define pthread_mutex_t CRITICAL_SECTION 2818 # define SWIG_MUTEX_INIT(var) var 2819 # else 2820 # include <pthread.h> 2821 # define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER 2822 # endif 2823 #endif 2824 2825 #ifdef __PTHREAD__ 2826 struct Guard 2812 # include "pythread.h" 2813 class Guard 2827 2814 { 2828 pthread_mutex_t *_mutex;2815 PyThread_type_lock & mutex_; 2829 2816 2830 Guard(pthread_mutex_t &mutex) : _mutex(&mutex) 2817 public: 2818 Guard(PyThread_type_lock & mutex) : mutex_(mutex) 2831 2819 { 2832 pthread_mutex_lock(_mutex);2820 PyThread_acquire_lock(mutex_, WAIT_LOCK); 2833 2821 } 2834 2822 2835 2823 ~Guard() 2836 2824 { 2837 pthread_mutex_unlock(_mutex);2825 PyThread_free_lock(mutex_); 2838 2826 } 2839 2827 }; 2840 2828 # define SWIG_GUARD(mutex) Guard _guard(mutex) … … 2905 2893 private: 2906 2894 typedef std::map<void*, GCItem_var> ownership_map; 2907 2895 mutable ownership_map owner; 2908 #ifdef __ PTHREAD__2909 static pthread_mutex_tswig_mutex_own;2896 #ifdef __THREAD__ 2897 static PyThread_type_lock swig_mutex_own; 2910 2898 #endif 2911 2899 2912 2900 public: … … 2951 2939 } 2952 2940 }; 2953 2941 2954 #ifdef __ PTHREAD__2955 pthread_mutex_t SWIG_MUTEX_INIT(Director::swig_mutex_own);2942 #ifdef __THREAD__ 2943 PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock(); 2956 2944 #endif 2957 2945 } 2958 2946