io/m_io_bwshaping.c
/*
 *  - Returns M_TIMEOUT_INF if no timeout is being enforced at this moment.
 *  - Returns 0 if timeout has elapsed
 *  - Returns number of milliseconds remaining in timeout otherwise
 */
- Returns M_TIMEOUT_INF if no timeout is being enforced at this moment.
- Returns 0 if timeout has elapsed
- Returns number of milliseconds remaining in timeout otherwise
- Returns M_TIMEOUT_INF if no timeout is being enforced at this moment . - Returns 0 if timeout has elapsed - Returns number of milliseconds remaining in timeout otherwise
static M_uint64 M_io_bwshaping_timeout_direction(M_io_handle_t *handle, M_io_bwshaping_direction_t direction)
{
	M_uint64 bw_nextms;
	M_uint64 l_nextms;
	if (direction == M_IO_BWSHAPING_DIRECTION_IN) {
		if (handle->settings.in_Bps == 0 && handle->settings.in_latency_ms == 0)
			return M_TIMEOUT_INF;
		if (!handle->in_waiting)
			return M_TIMEOUT_INF;
		bw_nextms = M_io_bwshaping_bwtrack_next_ms(handle->in_bw, handle->settings.in_Bps, handle->settings.in_period_s, handle->settings.in_sample_frequency_ms, handle->settings.in_mode);
	} else {
		if (handle->settings.out_Bps == 0 && handle->settings.out_latency_ms == 0)
			return M_TIMEOUT_INF;
		if (!handle->out_waiting)
			return M_TIMEOUT_INF;
		bw_nextms = M_io_bwshaping_bwtrack_next_ms(handle->out_bw, handle->settings.out_Bps, handle->settings.out_period_s, handle->settings.out_sample_frequency_ms, handle->settings.out_mode);
	}
	l_nextms  = M_io_bwshaping_latency_next_ms(handle, direction);
	return M_MAX(bw_nextms, l_nextms);
}
static M_uint64 M_io_bwshaping_timeout_direction ( M_io_handle_t * handle , M_io_bwshaping_direction_t direction ) { M_uint64 bw_nextms ; M_uint64 l_nextms ; if ( direction == M_IO_BWSHAPING_DIRECTION_IN ) { if ( handle -> settings . in_Bps == 0 && handle -> settings . in_latency_ms == 0 ) return M_TIMEOUT_INF ; if ( ! handle -> in_waiting ) return M_TIMEOUT_INF ; bw_nextms = M_io_bwshaping_bwtrack_next_ms ( handle -> in_bw , handle -> settings . in_Bps , handle -> settings . in_period_s , handle -> settings . in_sample_frequency_ms , handle -> settings . in_mode ) ; } else { if ( handle -> settings . out_Bps == 0 && handle -> settings . out_latency_ms == 0 ) return M_TIMEOUT_INF ; if ( ! handle -> out_waiting ) return M_TIMEOUT_INF ; bw_nextms = M_io_bwshaping_bwtrack_next_ms ( handle -> out_bw , handle -> settings . out_Bps , handle -> settings . out_period_s , handle -> settings . out_sample_frequency_ms , handle -> settings . out_mode ) ; } l_nextms = M_io_bwshaping_latency_next_ms ( handle , direction ) ; return M_MAX ( bw_nextms , l_nextms ) ; }
- Returns M_TIMEOUT_INF if no timeout is being enforced at this moment.
- Returns M_TIMEOUT_INF if no timeout is being enforced at this moment .
/* Not configured, so don't use timeouts */ /* Don't use a timer if we're not throttling */ /* Not configured, so don't use timeouts */ /* Don't use a timer if we're not throttling */