cvs: pear /PECL/threads threadapi.c

From: Date: Thu, 08 Aug 2002 10:14:20 +0000
Subject: cvs: pear /PECL/threads threadapi.c
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5624@lists.php.net to get a copy of this message
alan_k Thu Aug 8 06:14:20 2002 EDT Modified files: /pear/PECL/threads threadapi.c Log: first runthrough of posix pthreads compatibility Index: pear/PECL/threads/threadapi.c diff -u pear/PECL/threads/threadapi.c:1.4 pear/PECL/threads/threadapi.c:1.5 --- pear/PECL/threads/threadapi.c:1.4 Sun Aug 4 20:45:58 2002 +++ pear/PECL/threads/threadapi.c Thu Aug 8 06:14:20 2002 @@ -29,8 +29,9 @@ l->lock = tsrm_mutex_alloc(); l->event = thr_create_event(); #elif defined(PTHREADS) - pthread_mutex_init(&l->lock,NULL); - pthread_cond_init(&l->lock,NULL); + pthread_mutex_init(l->lock,NULL); + pthread_cond_init(l->event->cond,NULL); + #else #endif l->count = 0; @@ -44,8 +45,8 @@ tsrm_mutex_free(rwlock->lock); thr_close_event(rwlock->event); #elif defined(PTHREADS) - pthread_mutex_destroy(&rwlock->lock); - pthread_cond_destroy(&rwlock->event); + pthread_mutex_destroy(rwlock->lock); + pthread_cond_destroy(rwlock->event->cond); #else #endif free(rwlock); @@ -70,9 +71,9 @@ rwlock->count = -1; ReleaseMutex(rwlock->lock); #elif defined(PTHREADS) - pthread_mutex_lock(&rwlock->lock); + pthread_mutex_lock(rwlock->lock); while (rwlock->count != 0) - pthread_cond_wait(rwlock->event, rwlock->lock); + pthread_cond_wait(rwlock->event->cond, rwlock->lock); rwlock->count = -1; pthread_mutex_unlock(rwlock->lock); #else @@ -87,9 +88,9 @@ SetEvent(rwlock->event); ReleaseMutex(rwlock->lock); #elif defined(PTHREADS) - pthread_mutex_lock(&rwlock->lock); + pthread_mutex_lock(rwlock->lock); rwlock->count = 0; - pthread_cond_broadcast(rwlock->event); + pthread_cond_broadcast(rwlock->event->cond); pthread_mutex_unlock(rwlock->lock); #else #endif @@ -114,9 +115,9 @@ ++rwlock->count; ReleaseMutex(rwlock->lock); #elif defined(PTHREADS) - pthread_mutex_lock(&rwlock->lock); + pthread_mutex_lock(rwlock->lock); while (rwlock->count < 0) - pthread_cond_wait(rwlock->event, rwlock->lock); + pthread_cond_wait(rwlock->event->cond, rwlock->lock); ++rwlock->count; pthread_mutex_unlock(rwlock->lock); #else @@ -131,10 +132,10 @@ if (!rwlock->count) SetEvent(rwlock->event); ReleaseMutex(rwlock->lock); #elif defined(PTHREADS) - pthread_mutex_lock(&rwlock->lock); + pthread_mutex_lock(rwlock->lock); --rwlock->count; if (!rwlock->count) - pthread_cond_broadcast(rwlock->event); + pthread_cond_broadcast(rwlock->event->cond); pthread_mutex_unlock(rwlock->lock); #else #endif @@ -169,8 +170,13 @@ { #ifdef TSRM_WIN32 return WaitForSingleObject(event, timeout); -#elif defined(PTHREADS) - return pthread_cond_timedwait(event->cond, event->mutex, timeout); +#elif defined(PTHREADS) + struct timespec ts_timeout; + struct timeval now; + gettimeofday(&now); + ts_timeout.tv_sec = now.tv_sec; + ts_timeout.tv_nsec = now.tv_usec + timeout; + return pthread_cond_timedwait(event->cond, event->mutex, &ts_timeout); #elif defined(NETWARE) return -1; #elif defined(GNUPTH) @@ -285,7 +291,7 @@ #ifdef TSRM_WIN32 WaitForSingleObject(thread->thread, THR_INFINITE); #elif defined(PTHREADS) - pthread_join(thread->thread); + pthread_join(thread->thread,NULL); #elif defined(NETWARE) #elif defined(GNUPTH) #elif defined(NSAPI)

« previous php.pear.cvs (#5624) next »