[#BloombergLP-bslmt-Turnstile] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::Turnstile :relfileprefix: ../../ :mrdocs: Provide a mechanism to meter time at a configured event rate. == Synopsis Declared in `<bslmt_turnstile.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Turnstile; ---- == Description This class provides a mechanism to meter time. Using either the constructor or the `reset` method, the client specifies `rate`, indicating the number of events per second that the turnstile will allow. The client then calls `waitTurn`, which will either sleep until the next event is to occur, or return immediately if `waitTurn` was called after the next event is due. If `waitTurn` is not called until after the next event is due, the turnstile is said to be `lagging` behind, and calls to `waitTurn` will not sleep until the events have caught up with the schedule. Note that calling `waitTurn` a single time does not bring a turnstile back on schedule. For example, if a turnstile's configured frequency is one event per second, and the client is 10 seconds behind schedule, if `waitTurn` were subsequently called once per second, the turnstile will remain at 10 seconds behind schedule. The amount by which events are lagging behind the schedule can be determined via the `lagTime` method, which returns the positive number of microseconds by which the turnstile is lagging, or 0 if the turnstile is not behind schedule. == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslmt/Turnstile/2constructor.adoc[`Turnstile`] [.small]#[constructor]# | Create a turnstile that admits clients at the specified `rate`. | xref:BloombergLP/bslmt/Turnstile/lagTime.adoc[`lagTime`] | Return how far this turnstile lags behind schedule, in microseconds. | xref:BloombergLP/bslmt/Turnstile/reset.adoc[`reset`] | Reset this turnstile to admit clients at the specified `rate`. | xref:BloombergLP/bslmt/Turnstile/waitTurn.adoc[`waitTurn`] | Wait until the next turn may be taken, or return immediately. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#