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

Return the estimated wait before one more unit can be submitted&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bsls/TimeInterval.adoc[bsls::TimeInterval]
calculateTimeToSubmit(xref:BloombergLP/bsls/TimeInterval.adoc[bsls::TimeInterval] const& currentTime);
----

== Description

If 1 more unit can be submitted to this leaky bucket without causing it to overflow, then return a time interval of 0 immediately&period; Otherwise, first update the state of this leaky bucket to the specified `currentTime`&period; Then, return the estimated time interval that should pass from `currentTime` until 1 more unit can be submitted to this leaky bucket without causing it to overflow&period; The number of nanoseconds in the returned time interval is rounded up&period; Note that a time interval of 0 can still be return after the state of this leaky bucket has been updated to `currentTime`&period; Also note that after waiting for the returned time interval, clients should typically check again using this method, because additional units may have been submitted in the interim&period; The behavior is undefined unless `LLONG&lowbar;MIN !&equals; currentTime&period;seconds()` and the total number of seconds in the time interval resulting from `currentTime &hyphen; lastUpdateTime()` can be represented with a 64&hyphen;bit signed integer&period;

== Return Value

estimated time until 1 more unit can be submitted without overflow, or 0 if it can be submitted immediately

== Parameters

[cols="1,4"]
|===
| Name| Description
| *currentTime*
| time used to update and measure against this bucket
|===


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