- if (queue->capacity != 0 && queue->capacity == xbt_dynar_length(queue->data)) {
- DEBUG2("Capacity of %p exceded (=%d). Waiting",queue,queue->capacity);
- xbt_cond_timedwait(queue->not_full,queue->mutex, delay);
- /* check if a timeout occurs */
- if (xbt_os_time() >= timeout) {
- xbt_mutex_unlock(queue->mutex);
- THROW1(timeout_error,0,"Timeout (delay was %f)",delay);
- }
+ while ( (queue->capacity != 0) && (queue->capacity == xbt_dynar_length(queue->data)) && (xbt_time() < timeout) ) {
+ DEBUG2("Capacity of %p exceded (=%d). Waiting",queue,queue->capacity);
+ xbt_cond_timedwait(queue->not_full,queue->mutex, timeout - xbt_time());