RKH
Loading...
Searching...
No Matches
rkhqueue.h File Reference

Specifies the interface of the queue services. More...

#include "rkhcfg.h"
#include "rkhtype.h"
Include dependency graph for rkhqueue.h:

Go to the source code of this file.

Data Structures

struct  RKH_QUEI_T
 Defines the data structure into which the performance information for queues is stored. More...
 
struct  RKH_QUEUE_T
 Defines the data structure used to maintain information about the queue. More...
 

Macros

#define RKH_QUEUE_IS_EMPTY(q)    (rbool_t)(rkh_queue_get_num((RKH_QUEUE_T *)(q)) == 0)
 This macro query the queue.
 

Typedefs

typedef rui8_t RKH_QUENE_T
 This data type defines the maximum number of elements that any queue can contain.
 

Enumerations

enum  RKHQueueType {
  RegularQueType ,
  PriorityQueType
}
 Queue types. More...
 
enum  RKH_QUECODE_T
 Return codes from queue operations.
 

Functions

void rkh_queue_init (RKH_QUEUE_T *q, const void **sstart, RKH_QUENE_T ssize, void *sma)
 Initializes the previously allocated queue data structure RKH_QUEUE_T.
 
rbool_t rkh_queue_is_full (RKH_QUEUE_T *q)
 This function query the queue.
 
RKH_QUENE_T rkh_queue_get_num (RKH_QUEUE_T *q)
 Returns the number of elements currently in the queue.
 
RKH_QUENE_T rkh_queue_get_lwm (RKH_QUEUE_T *q)
 This function returns the lowest number of free elements ever present in the pool. This number provides valuable empirical data for proper sizing of the queue.
 
void * rkh_queue_get (RKH_QUEUE_T *q)
 Get and remove an element from a queue.
 
void rkh_queue_put_fifo (RKH_QUEUE_T *q, const void *pe)
 Puts an element on a queue in a FIFO manner. The element is queued by reference, not by copy.
 
void rkh_queue_put_lifo (RKH_QUEUE_T *q, const void *pe)
 Puts an element on a queue in a LIFO manner. The element is queued by reference, not by copy.
 
void rkh_queue_deplete (RKH_QUEUE_T *q)
 Depletes a queue. Empties the contents of the queue and eliminates all stored elements.
 
ruint rkh_queue_read (RKH_QUEUE_T *q, void *pe)
 Read an element from a queue without remove it.
 
void rkh_queue_get_info (RKH_QUEUE_T *q, RKH_QUEI_T *pqi)
 Retrieves performance information for a particular queue.
 
void rkh_queue_clear_info (RKH_QUEUE_T *q)
 Clear performance information for a particular queue.
 
void rkh_queue_setType (RKH_QUEUE_T *q, RKHQueueType type)
 Sets the type of the queue.
 

Detailed Description

Specifies the interface of the queue services.

Definition in file rkhqueue.h.

Typedef Documentation

◆ RKH_QUENE_T

typedef rui8_t RKH_QUENE_T

This data type defines the maximum number of elements that any queue can contain.

The valid values [in bits] are 8, 16 or 32. Default is 8. This type is configurable via the preprocessor switch RKH_CFG_QUE_SIZEOF_NELEM.

Definition at line 123 of file rkhqueue.h.

Enumeration Type Documentation

◆ RKHQueueType

Queue types.

This enumeration defines the available queue types, which determine the order in which elements are retrieved from the queue.

Enumerator
RegularQueType 

Elements are retrieved in FIFO (First-In, First-Out) order.

PriorityQueType 

Elements are retrieved based on their priority, with the highest priority element being retrieved first.

Definition at line 93 of file rkhqueue.h.

Function Documentation

◆ rkh_queue_setType()

void rkh_queue_setType ( RKH_QUEUE_T q,
RKHQueueType  type 
)

Sets the type of the queue.

This function sets the type of the queue, which determines how elements are retrieved (e.g., FIFO or priority-based).

Note
Keep in mind that setting the queue type to PriorityQueType will increase the computational complexity of rkh_queue_get from O(1) to O(n), where n is the number of elements in the queue.
Parameters
[in]qPointer to the queue object (RKH_QUEUE_T).
[in]typeThe desired queue type (RKHQueueType).