qos_queue.h File Reference

Inline implementation of a Queue (FIFO) of qres_time_t values. More...

#include <linux/aquosa/qos_memory.h>
#include <linux/aquosa/qos_debug.h>
#include <linux/aquosa/qos_types.h>

Go to the source code of this file.

Data Structures

struct  qos_queue_t
 The internal representation of a queue. More...

Defines

#define QOS_QUEUE_CHECK_OPS
 Enable various checks, like dynamic array existence and check of full or empty queue on insertion and extraction operations.

Functions

static __inline qos_rv qos_queue_init (qos_queue_t *queue, int max_num_elems)
 Initialize a queue with the specified maximum number of elements.
static __inline void qos_queue_final (qos_queue_t *queue)
static __inline qos_rv qos_queue_insert (qos_queue_t *queue, qres_time_t elem)
static __inline qres_time_t qos_queue_extract (qos_queue_t *queue)
 Extract an element from the queue.
static __inline qres_time_t qos_queue_shift (qos_queue_t *queue, qres_time_t elem)
 Insert and extract an element in a single operation.
static __inline qres_time_t qos_queue_peek (qos_queue_t *queue)
 Get next element to be extracted, but do not extract it.
static __inline qres_time_t qos_queue_get_at (qos_queue_t *queue, int pos)
 Get element at specified position of the queue.
static __inline qos_rv qos_queue_set_at (qos_queue_t *queue, int pos, qres_time_t elem)
 Set element at specified position, where element at position 0 is the next one that would be retrieved by the qos_queue_peek() function.
static __inline int qos_queue_get_num_elements (qos_queue_t *queue)
 Get the current queue size, i.e.
static __inline int qos_queue_get_max_num_elements (qos_queue_t *queue)
 Get the maximum queue size, i.e.

Detailed Description

Inline implementation of a Queue (FIFO) of qres_time_t values.

All queue operations are declared as static inline, and their implementation is in the header file itself, so to allow the compiler to optimize as much as possible. It is possible to enable or disable various checks on the consistency of each opearation with respect to the internal status of the queue object. This is useful for debugging purposes.

Definition in file qos_queue.h.


Function Documentation

static __inline qres_time_t qos_queue_extract ( qos_queue_t queue  )  [static]

Extract an element from the queue.

Returns:
The extracted element, if positive, or QOS_E_INCONSISTENT_STATE if the queue was empty at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 77 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, qos_queue_t::max_num_elements, and qos_queue_t::num_elements.

static __inline qres_time_t qos_queue_get_at ( qos_queue_t queue,
int  pos 
) [static]

Get element at specified position of the queue.

Element at position 0 is the latest inserted one, and element at position qos_queue_get_num_elements()-1 is the oldest element in the queue, i.e. the next one that would be retrieved by a the qos_queue_peek() function.

Returns:
The element at the specified position, if positive, or QOS_E_INCONSISTENT_STATE if pos is greater than or equal to the queue size at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 135 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, qos_queue_t::max_num_elements, and qos_queue_t::num_elements.

static __inline int qos_queue_get_max_num_elements ( qos_queue_t queue  )  [static]

Get the maximum queue size, i.e.

the maximum number of elements that can be enqueued.

Returns:
The maximum queue size, if positive, or QOS_E_INCONSISTENT_STATE if the queue has not been initialized at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 180 of file qos_queue.h.

References qos_queue_t::data, and qos_queue_t::max_num_elements.

static __inline int qos_queue_get_num_elements ( qos_queue_t queue  )  [static]

Get the current queue size, i.e.

the number of enqueued elements.

Returns:
The current queue size, if positive, or QOS_E_INCONSISTENT_STATE if the queue was empty at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 166 of file qos_queue.h.

References qos_queue_t::data, and qos_queue_t::num_elements.

static __inline qos_rv qos_queue_init ( qos_queue_t queue,
int  max_num_elems 
) [static]

Initialize a queue with the specified maximum number of elements.

The array for containing, at most, the specified number of elements of type qres_time_t is dynamically allocated by using the qos_memory.h interface, so that it works both from user space and from kernel space.

Parameters:
queue Pointer to the qos_queue_t object
max_num_elems Maximum number of enqueued elements
Returns:
QOS_OK or QOS_E_NO_MEMORY

Definition at line 45 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, qos_queue_t::ins_pos, qos_queue_t::max_num_elements, and qos_queue_t::num_elements.

static __inline qres_time_t qos_queue_peek ( qos_queue_t queue  )  [static]

Get next element to be extracted, but do not extract it.

Returns:
The next element to be extracted, if positive, or QOS_E_INCONSISTENT_STATE if the queue was empty at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 114 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, and qos_queue_t::num_elements.

static __inline qos_rv qos_queue_set_at ( qos_queue_t queue,
int  pos,
qres_time_t  elem 
) [static]

Set element at specified position, where element at position 0 is the next one that would be retrieved by the qos_queue_peek() function.

Returns:
QOS_E_INCONSISTENT_STATE if pos is greater than or equal to the queue size at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 151 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, qos_queue_t::max_num_elements, and qos_queue_t::num_elements.

static __inline qres_time_t qos_queue_shift ( qos_queue_t queue,
qres_time_t  elem 
) [static]

Insert and extract an element in a single operation.

Returns:
The extracted element, if positive, or QOS_E_INCONSISTENT_STATE if the queue was empty at the time of call and QOS_QUEUE_CHECK_OPS is defined.

Definition at line 95 of file qos_queue.h.

References qos_queue_t::data, qos_queue_t::del_pos, qos_queue_t::ins_pos, and qos_queue_t::max_num_elements.

Generated on Mon Aug 2 22:38:48 2010 for qosmgr by  doxygen 1.6.3