[#BloombergLP-balm-PublicationScheduler]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balm.adoc[balm]::PublicationScheduler
:relfileprefix: ../../
:mrdocs:

This class defines a mechanism for scheduling the periodic publication of metrics&period; Each publication scheduler object is supplied the address of a `MetricsManager` and a `bdlmt&colon;&colon;TimerEventScheduler` at construction&period; The metrics manager is used to publish metrics, while the timer&hyphen;event scheduler provides the underlying scheduling mechanism&period; Metrics are scheduled for publication using the `scheduleCategory` and `setDefaultSchedule` methods&period; The `scheduleCategory` method schedules an individual category to be publisher periodically at the provided interval, whereas `setDefaultSchedule` schedules the periodic publication of any category not given an individual schedule&period; The publication scheduler will create a recurring timer for each unique time interval supplied, and will group together categories that share a common time interval into a single call to `MetricsManager&colon;&colon;publish`&period; Note that it is left unspecified whether publication events that occur on a common multiple of _different_ intervals will be grouped into a single invocation of `MetricsManager&colon;&colon;publish`&period;

== Synopsis

Declared in `&lt;balm&lowbar;publicationscheduler&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class PublicationScheduler;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/PublicationScheduler/2constructor.adoc[`PublicationScheduler`]         [.small]#[constructor]#
| Create a publication scheduler that will use the specified `metricsManager` to publish metrics, and the specified `eventScheduler` to supply timer events&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;
| xref:BloombergLP/balm/PublicationScheduler/2destructor.adoc[`&#126;PublicationScheduler`] [.small]#[destructor]#
| Destroy this publication scheduler and cancel any pending publications&period; Note that, if any metrics are currently being published, this operation will block until all of their publications have completed&period;
| xref:BloombergLP/balm/PublicationScheduler/cancelAll.adoc[`cancelAll`] 
| Cancel all periodic publication of metrics&period; This operation (atomically) clears the default publication schedule and cancels the publication schedule of any category individually scheduled using the `scheduleCategory` method&period; Any scheduled publication is either canceled or completed before this method returns&period;
| xref:BloombergLP/balm/PublicationScheduler/cancelCategorySchedule-06.adoc[`cancelCategorySchedule`] 
| `cancelCategorySchedule` overloads
| xref:BloombergLP/balm/PublicationScheduler/clearDefaultSchedule.adoc[`clearDefaultSchedule`] 
| If the default publication schedule has been set (using `setDefaultSchedule`), cancel that periodic default publication, and return 0&period; This method has no effect and will return a non&hyphen;zero value if a default publication schedule has not been set&period; Any scheduled publication is either canceled or completed before this method returns&period;
| xref:BloombergLP/balm/PublicationScheduler/findCategorySchedule-06.adoc[`findCategorySchedule`] 
| `findCategorySchedule` overloads
| xref:BloombergLP/balm/PublicationScheduler/getCategorySchedule-09.adoc[`getCategorySchedule`] 
| `getCategorySchedule` overloads
| xref:BloombergLP/balm/PublicationScheduler/getDefaultSchedule.adoc[`getDefaultSchedule`] 
| Load into the specified `result` the default scheduled interval, (set using the `setDefaultSchedule` method), for periodically publishing metrics, if found, and return `true`, or (if not found) return `false` with no effect&period;
| xref:BloombergLP/balm/PublicationScheduler/manager-08.adoc[`manager`] 
| `manager` overloads
| xref:BloombergLP/balm/PublicationScheduler/print.adoc[`print`] 
| Print a formatted string describing the current state of this `PublicationScheduler` object to the specified `stream` at the (absolute value of) the optionally specified indentation `level` and return a reference to `stream`&period; If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, suppress all indentation AND format the entire output on one line&period; If `stream` is not valid on entry, this operation has no effect&period; Note that this is provided primarily for debugging purposes&period;
| xref:BloombergLP/balm/PublicationScheduler/scheduleCategory-0b.adoc[`scheduleCategory`] 
| `scheduleCategory` overloads
| xref:BloombergLP/balm/PublicationScheduler/setDefaultSchedule.adoc[`setDefaultSchedule`] 
| Set, to the specified `interval`, the default interval for metrics to be periodically published using the `MetricsManager` supplied at construction&period; This method schedules every metric category not given a individual schedule (using `scheduleCategory`), to be published periodically until that category is either given an individual schedule, or the default schedule is canceled (using either `clearDefaultSchedule` or `cancelAllPublications`)&period; If a default publication has _already_ been scheduled, change its schedule to `interval`&semi; any previously scheduled publication is either canceled or completed (atomically) before rescheduling&period; If the default publication is rescheduled with the same `interval` as it is currently scheduled, this operation has no effect&period; The behavior is undefined unless `bsls&colon;&colon;TimeInterval(0, 0) &lt; interval`&period; Note that, to exclude a category from any publication, clients can disable the category using the `MetricsManager` object supplied at construction&period;
| xref:BloombergLP/balm/PublicationScheduler/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;PublicationScheduler, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/balm/PublicationScheduler_Proctor.adoc[BloombergLP::balm::PublicationScheduler&lowbar;Proctor]`
| defined in implementation
|===


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