int schro_async_wait_locked (SchroAsync * async) { struct timespec ts; int ret; #ifdef HAVE_CLOCK_GETTIME clock_gettime (CLOCK_REALTIME, &ts); #else { struct timeval tv; gettimeofday (&tv, NULL); ts.tv_sec = tv.tv_sec; ts.tv_nsec = tv.tv_usec * 1000; } #endif ts.tv_sec += 1; ret = pthread_cond_timedwait (&async->app_cond, &async->mutex, &ts); if (ret != 0) { int i; for (i = 0; i < async->n_threads; i++) { if (async->threads[i].busy != 0) break; } if (i == async->n_threads) { SCHRO_WARNING ("timeout. deadlock?"); schro_async_dump (async); return FALSE; } } return TRUE; }
int schro_async_wait_locked (SchroAsync *async) { DWORD ret; LeaveCriticalSection (&async->mutex); ret = WaitForSingleObject (async->app_event, 1000); EnterCriticalSection (&async->mutex); if (ret == WAIT_TIMEOUT) { int i; for(i=0;i<async->n_threads;i++){ if (async->threads[i].busy) { SCHRO_DEBUG("thread %d is busy", i); break; } } if (i == async->n_threads) { SCHRO_WARNING("timeout. deadlock?"); schro_async_dump (async); return FALSE; } } return TRUE; }
int schro_async_wait_locked (SchroAsync * async) { GTimeVal ts; int ret; g_get_current_time (&ts); g_time_val_add (&ts, 1000000); ret = g_cond_timed_wait (async->app_cond, async->mutex, &ts); if (!ret) { int i; for (i = 0; i < async->n_threads; i++) { if (async->threads[i].busy != 0) break; } if (i == async->n_threads) { SCHRO_WARNING ("timeout. deadlock?"); schro_async_dump (async); return FALSE; } } return TRUE; }