Resource Tuner
Loading...
Searching...
No Matches
OrderedQueue Class Referenceabstract

This class represents a mutex-protected multiple producer, single consumer priority queue. More...

#include <OrderedQueue.h>

Public Member Functions

int8_t addAndWakeup (Message *req)
 Used by the producers to add a new request to the OrderedQueue.
 
virtual void orderedQueueConsumerHook ()=0
 Provides a mechanism, to hook or plug-in the Consumer Code.
 
Messagepop ()
 Used by the consumer end to poll a request from the OrderedQueue.
 
void wait ()
 Used by the Consumer end to wait for Requests.
 
int8_t hasPendingTasks ()
 Used by the consumer to check if there are any pending requests in the OrderedQueue.
 

Protected Attributes

std::priority_queue< Message *, std::vector< Message * >, QueueOrdering > mOrderedQueue
 Core OrderedQueue Data Structure, to store the Requests pushed by the Publisher threads. Makes use of std::priority_queue, which is ordered here based on the Request Priorities.
 

Detailed Description

This class represents a mutex-protected multiple producer, single consumer priority queue.

The Queue items are ordered by their Priority, so that the Queue Item with the highest Priority is always served first.

Definition at line 22 of file OrderedQueue.h.

Member Function Documentation

◆ addAndWakeup()

int8_t OrderedQueue::addAndWakeup ( Message req)

Used by the producers to add a new request to the OrderedQueue.

This routine will wake up the consumer end to process the task.

Parameters
reqPointer to the Request
Returns
int8_t:
  • 1: If the Request was successfully added to the Request Queue
  • 0: otherwise

◆ hasPendingTasks()

int8_t OrderedQueue::hasPendingTasks ( )

Used by the consumer to check if there are any pending requests in the OrderedQueue.

Returns
int8_t:
  • 1: If there are pending Requests
  • 0: otherwise

◆ orderedQueueConsumerHook()

virtual void OrderedQueue::orderedQueueConsumerHook ( )
pure virtual

Provides a mechanism, to hook or plug-in the Consumer Code.

Using this routine, the consumer can safely (lock-protected) extract and process Requests enqueued by the Producers.

Implemented in RequestQueue, and SignalQueue.

◆ pop()

Message * OrderedQueue::pop ( )

Used by the consumer end to poll a request from the OrderedQueue.

This routine will return the Request with the highest priority to the consumer and remove it from the OrderedQueue. If the OrderedQueue is empty this function returns a null pointer.

Returns
void*:
  • Pointer to the request polled

◆ wait()

void OrderedQueue::wait ( )

Used by the Consumer end to wait for Requests.

This routine will put the consumer to sleep.


The documentation for this class was generated from the following file: