[#BloombergLP-bdlcc-MultipriorityQueue] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::MultipriorityQueue :relfileprefix: ../../ :mrdocs: This class implements a thread‐enabled multipriority queue whose priorities are restricted to a (small) set of contiguous `N` integer values, `[ 0 .. N ‐ 1 ]`, with 0 being the most urgent. == Synopsis Declared in `<bdlcc_multipriorityqueue.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class MultipriorityQueue; ---- == Description This class does have a notion of value, namely the sequence of priority/element pairs, constrained to be in decreasing order of urgency (i.e., monotonically increasing priority values). However, no value‐semantic operations are implemented. Note that elements having the same priority are maintained in First‐In‐First‐Out (FIFO) order. Note that the current implementation supports up to a maximum of `sizeof(int) * CHAR_BIT` priorities. This class is implemented as a set of linked lists, one for each priority. Two vectors are used to maintain head and tail pointers for the lists. == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlcc/MultipriorityQueue/2constructor-0d.adoc[`MultipriorityQueue`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlcc/MultipriorityQueue/2destructor.adoc[`~MultipriorityQueue`] [.small]#[destructor]# | Destroy this container. The behavior is undefined unless all access or modification of the container has completed prior to this call. | xref:BloombergLP/bdlcc/MultipriorityQueue/disable.adoc[`disable`] | Disable pushes to this multipriority queue. This method has no effect unless the queue was enabled. | xref:BloombergLP/bdlcc/MultipriorityQueue/enable.adoc[`enable`] | Enable pushes to this multipriority queue. This method has no effect unless the queue was disabled. | xref:BloombergLP/bdlcc/MultipriorityQueue/isEmpty.adoc[`isEmpty`] | Return `true` if there are no items in this multi‐priority queue, and `false` otherwise. | xref:BloombergLP/bdlcc/MultipriorityQueue/isEnabled.adoc[`isEnabled`] | Return `true` if this multipriority queue is enable and `false` otherwise. | xref:BloombergLP/bdlcc/MultipriorityQueue/length.adoc[`length`] | Return the total number of items in this multi‐priority queue. | xref:BloombergLP/bdlcc/MultipriorityQueue/numPriorities.adoc[`numPriorities`] | Return the number of distinct priorities (indicated at construction) that are supported by this multi‐priority queue. | xref:BloombergLP/bdlcc/MultipriorityQueue/popFront.adoc[`popFront`] | Remove the least‐recently added item having the most urgent priority (lowest value) from this multi‐priority queue and load its value into the specified `item`. If this queue is empty, this method blocks the calling thread until an item becomes available. If the optionally specified `itemPriority` is non‐null, load the priority of the popped item into `itemPriority`. The behavior is undefined unless `item` is non‐null. Note this is unaffected by the enabled / disabled state of the queue. | xref:BloombergLP/bdlcc/MultipriorityQueue/pushBack-03.adoc[`pushBack`] | `pushBack` overloads | xref:BloombergLP/bdlcc/MultipriorityQueue/pushBackMultipleRaw.adoc[`pushBackMultipleRaw`] | Insert the value of the specified `item` with the specified `itemPriority` onto the back of this multipriority queue before any queued items having a less urgent priority (higher value) than `itemPriority`, and after any items having the same or more urgent priority (lower value) than `itemPriority`. All of the specified `numItems` items are pushed as a single atomic action, unless the copy constructor for one of them throws an exception, in which case a possibly empty subset of the pushes will have completed and no memory will be leaked. `Raw` means that the push will succeed even if the multipriority queue is disabled. Note that this method is targeted for specific use by the class `bdlmt::MultipriorityThreadPool`. The behavior is undefined unless `0 <= itemPriority < numPriorities()`. | xref:BloombergLP/bdlcc/MultipriorityQueue/pushFrontMultipleRaw.adoc[`pushFrontMultipleRaw`] | Insert the value of the specified `item` with the specified `itemPriority` into the front of this multipriority queue the specified `numItems` times, before any queued items having the same or less urgent priority (higher value) than `itemPriority`, and after any items having more urgent priority (lower value) than `itemPriority`. All `numItems` items are pushed as a single atomic action, unless the copy constructor throws while creating one of them, in which case a possibly empty subset of the pushes will have completed and no memory will be leaked. `Raw` means that the push will succeed even if the multipriority queue is disabled. The behavior is undefined unless `0 <= itemPriority < numPriorities()`. Note that this method is targeted at specific uses by the class `bdlmt::MultipriorityThreadPool`. | xref:BloombergLP/bdlcc/MultipriorityQueue/removeAll.adoc[`removeAll`] | Remove and destroy all items from this multi‐priority queue. | xref:BloombergLP/bdlcc/MultipriorityQueue/tryPopFront.adoc[`tryPopFront`] | Attempt to remove (immediately) the least‐recently added item having the most urgent priority (lowest value) from this multi‐priority queue. On success, load the value of the popped item into the specified `item`; if the optionally specified `itemPriority` is non‐null, load the priority of the popped item into `itemPriority`; and return 0. Otherwise, leave `item` and `itemPriority` unmodified, and return a non‐zero value indicating that this queue was empty. The behavior is undefined unless `item` is non‐null. Note this is unaffected by the enabled / disabled state of the queue. | xref:BloombergLP/bdlcc/MultipriorityQueue/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<MultipriorityQueue, UsesBslmaAllocator>`] | |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#