[#BloombergLP-balb-LeakyBucket-calculateTimeWindow]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balb.adoc[balb]::xref:BloombergLP/balb/LeakyBucket.adoc[LeakyBucket]::calculateTimeWindow
:relfileprefix: ../../../
:mrdocs:

Return the time window approximated by a leaky bucket of given size&period;

== Synopsis

Declared in `&lt;balb&lowbar;leakybucket&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
xref:BloombergLP/bsls/TimeInterval.adoc[bsls::TimeInterval]
calculateTimeWindow(
    xref:BloombergLP/bsls/Types/Uint64.adoc[bsls::Types::Uint64] drainRate,
    xref:BloombergLP/bsls/Types/Uint64.adoc[bsls::Types::Uint64] capacity);
----

== Description

Return the time interval over which a leaky bucket _approximates_ a moving&hyphen;total of submitted units, as the rounded&hyphen;down ratio between the specified `capacity` and the specified `drainRate`&period; If the rounded ratio is 0, return a time interval of 1 nanosecond&period; The behavior is undefined unless `drainRate &gt; 0` and `capacity &sol; drainRate` can be represented with 64&hyphen;bit signed integral type&period;

== Return Value

time interval approximating the moving&hyphen;total window for the given capacity and drain rate

== Parameters

[cols="1,4"]
|===
| Name| Description
| *drainRate*
| rate at which units drain from the bucket
| *capacity*
| capacity of the leaky bucket in units
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
