diff options
author | Zeev Suraski <zeev@php.net> | 1999-12-20 20:02:25 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 1999-12-20 20:02:25 +0000 |
commit | 469966917b33f97d0d03e51d409c5f93f48a8969 (patch) | |
tree | d9b17912313984a1349d281a823a72ed227d547d /TSRM/TSRM.c | |
parent | a2cc070fc2c99174bcf6bb002b03658f9e554504 (diff) | |
download | php-git-469966917b33f97d0d03e51d409c5f93f48a8969.tar.gz |
Use Critical Sections under Win32 - shows roughly 40% performance increase under
multithreaded Win32!
Diffstat (limited to 'TSRM/TSRM.c')
-rw-r--r-- | TSRM/TSRM.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index 8cf563075b..1f7da18d88 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -326,7 +326,8 @@ TSRM_API MUTEX_T tsrm_mutex_alloc( void ) MUTEX_T mutexp; #ifdef WIN32 - mutexp = CreateMutex(NULL,FALSE,NULL); + mutexp = malloc(sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(mutexp); #elif defined(GNUPTH) mutexp = (MUTEX_T) malloc(sizeof(*mutexp)); pth_mutex_init(mutexp); @@ -350,7 +351,7 @@ TSRM_API void tsrm_mutex_free( MUTEX_T mutexp ) { if (mutexp) { #ifdef WIN32 - CloseHandle(mutexp); + DeleteCriticalSection(mutexp); #elif defined(GNUPTH) free(mutexp); #elif defined(PTHREADS) @@ -375,7 +376,8 @@ TSRM_API int tsrm_mutex_lock( MUTEX_T mutexp ) tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id()); #endif #ifdef WIN32 - return WaitForSingleObject(mutexp,1000); + EnterCriticalSection(mutexp); + return 1; #elif defined(GNUPTH) return pth_mutex_acquire(mutexp, 0, NULL); #elif defined(PTHREADS) @@ -395,7 +397,8 @@ TSRM_API int tsrm_mutex_unlock( MUTEX_T mutexp ) tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id()); #endif #ifdef WIN32 - return ReleaseMutex(mutexp); + LeaveCriticalSection(mutexp); + return 1; #elif defined(GNUPTH) return pth_mutex_release(mutexp); #elif defined(PTHREADS) |