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

Return the time interval required to drain the specified units&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]
calculateDrainTime(
    xref:BloombergLP/bsls/Types/Uint64.adoc[bsls::Types::Uint64] numUnits,
    xref:BloombergLP/bsls/Types/Uint64.adoc[bsls::Types::Uint64] drainRate,
    bool ceilFlag);
----

== Description

Return the time interval required to drain the specified `numUnits` at the specified `drainRate`, round up the number of nanoseconds in the time interval if the specified `ceilFlag` is set to `true`, otherwise, round down the number of nanoseconds&period; The behavior is undefined unless the number of seconds in the calculated interval may be represented by a 64&hyphen;bit signed integral type&period;

== Return Value

time interval required to drain `numUnits` at `drainRate`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *numUnits*
| number of units to drain
| *drainRate*
| rate at which units drain
| *ceilFlag*
| if `true`, round nanoseconds up&semi; otherwise round down
|===


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