[#BloombergLP-bdlmt-ThreadMultiplexor]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::ThreadMultiplexor
:relfileprefix: ../../
:mrdocs:

Mechanism that partitions threads to process user&hyphen;defined jobs&period;

== Synopsis

Declared in `&lt;bdlmt&lowbar;threadmultiplexor&period;h&gt;`

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

== Description

This class provides a mechanism for facilitating the use of multiple threads to perform various user&hyphen;defined functions (&quot;jobs&quot;) when some degree of collaboration between threads is required&period; The thread multiplexor is configured with a total number of &quot;processors&quot;, representing the number of threads that may process jobs at any particular time&period; Additional threads enqueue jobs to a pending job queue, which is processed by the next available processing thread&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/ThreadMultiplexor/Job.adoc[`Job`] 
| A callback of this type may be passed to the `processJob` method&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/ThreadMultiplexor/2constructor.adoc[`ThreadMultiplexor`]         [.small]#[constructor]#
| Create a thread multiplexor with the specified processor and queue limits&period;
| xref:BloombergLP/bdlmt/ThreadMultiplexor/2destructor.adoc[`&#126;ThreadMultiplexor`] [.small]#[destructor]#
| Destroy this thread multiplexor object&period;
| xref:BloombergLP/bdlmt/ThreadMultiplexor/maxProcessors.adoc[`maxProcessors`] 
| Return the maximum number of active processors&period;
| xref:BloombergLP/bdlmt/ThreadMultiplexor/numProcessors.adoc[`numProcessors`] 
| Return the current number of active processors&period;
| xref:BloombergLP/bdlmt/ThreadMultiplexor/processJob.adoc[`processJob`] 
| Process or enqueue the specified `job` based on available processors&period;
| xref:BloombergLP/bdlmt/ThreadMultiplexor/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;ThreadMultiplexor, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===



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