"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "locks/win32/thread_cond.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

thread_cond.c  (apr-1.6.5.tar.bz2):thread_cond.c  (apr-1.7.0.tar.bz2)
skipping to change at line 64 skipping to change at line 64
apr_pool_cleanup_null); apr_pool_cleanup_null);
return APR_SUCCESS; return APR_SUCCESS;
} }
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
{ {
return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup);
} }
static APR_INLINE apr_status_t _thread_cond_timedwait(apr_thread_cond_t *cond, static APR_INLINE apr_status_t thread_cond_timedwait(apr_thread_cond_t *cond,
apr_thread_mutex_t *mutex, apr_thread_mutex_t *mutex,
DWORD timeout_ms ) apr_interval_time_t timeout
)
{ {
DWORD res; DWORD res;
apr_status_t rv; apr_status_t rv;
unsigned int wake = 0; unsigned int wake = 0;
unsigned long generation; unsigned long generation;
DWORD timeout_ms = 0;
EnterCriticalSection(&cond->csection); EnterCriticalSection(&cond->csection);
cond->num_waiting++; cond->num_waiting++;
generation = cond->generation; generation = cond->generation;
LeaveCriticalSection(&cond->csection); LeaveCriticalSection(&cond->csection);
apr_thread_mutex_unlock(mutex); apr_thread_mutex_unlock(mutex);
do { do {
res = WaitForSingleObject(cond->semaphore, timeout_ms); apr_interval_time_t t = timeout;
do {
if (t < 0) {
timeout_ms = INFINITE;
}
else if (t > 0) {
/* Given timeout is 64bit usecs whereas Windows timeouts are
* 32bit msecs and below INFINITE (2^32 - 1), so we may need
* multiple timed out waits...
*/
if (t > apr_time_from_msec(INFINITE - 1)) {
timeout_ms = INFINITE - 1;
t -= apr_time_from_msec(INFINITE - 1);
}
else {
timeout_ms = (DWORD)apr_time_as_msec(t);
t = 0;
}
}
res = WaitForSingleObject(cond->semaphore, timeout_ms);
} while (res == WAIT_TIMEOUT && t > 0);
EnterCriticalSection(&cond->csection); EnterCriticalSection(&cond->csection);
if (cond->num_wake) { if (cond->num_wake) {
if (cond->generation != generation) { if (cond->generation != generation) {
cond->num_wake--; cond->num_wake--;
cond->num_waiting--; cond->num_waiting--;
rv = APR_SUCCESS; rv = APR_SUCCESS;
break; break;
} else { } else {
skipping to change at line 118 skipping to change at line 140
LeaveCriticalSection(&cond->csection); LeaveCriticalSection(&cond->csection);
apr_thread_mutex_lock(mutex); apr_thread_mutex_lock(mutex);
return rv; return rv;
} }
APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
apr_thread_mutex_t *mutex) apr_thread_mutex_t *mutex)
{ {
return _thread_cond_timedwait(cond, mutex, INFINITE); return thread_cond_timedwait(cond, mutex, (apr_interval_time_t)-1);
} }
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
apr_thread_mutex_t *mutex, apr_thread_mutex_t *mutex,
apr_interval_time_t timeout) apr_interval_time_t timeout)
{ {
DWORD timeout_ms = (DWORD) apr_time_as_msec(timeout); return thread_cond_timedwait(cond, mutex, timeout);
return _thread_cond_timedwait(cond, mutex, timeout_ms);
} }
APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond) APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
{ {
unsigned int wake = 0; unsigned int wake = 0;
EnterCriticalSection(&cond->csection); EnterCriticalSection(&cond->csection);
if (cond->num_waiting > cond->num_wake) { if (cond->num_waiting > cond->num_wake) {
wake = 1; wake = 1;
cond->num_wake++; cond->num_wake++;
 End of changes. 5 change blocks. 
8 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)