Hi,

On 2013-09-03 14:35:18 +0200, Antonin Houska wrote:

> +             /*
> +              * THROTTLING_SAMPLE_MIN / MAX_RATE_LOWER (in seconds) should 
> be the
> +              * longest possible time to sleep.
> +              */
> +             pg_usleep((long) sleep);
> +     else
> +
> +             /*
> +              * The actual transfer rate is below the limit. Negative value 
> would
> +              * distort the adjustment of throttled_last.
> +              */
> +             sleep = 0;
> +
> +     /*
> +      * Only the whole multiples of throttling_sample processed. The rest 
> will
> +      * be done during the next call of this function.
> +      */
> +     throttling_counter %= throttling_sample;
> +     /* Once the (possible) sleep ends, new period starts. */
> +     throttled_last += elapsed + sleep;
> +}

It's probably better to use latches for the waiting, those have properly
defined interruption semantics. Whether pg_usleep will be interrupted is
platform dependant...

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to