RKH
Loading...
Searching...
No Matches
rkhqueue.h
Go to the documentation of this file.
1/*
2 * --------------------------------------------------------------------------
3 *
4 * Framework RKH
5 * -------------
6 *
7 * State-machine framework for reactive embedded systems
8 *
9 * Copyright (C) 2010 Leandro Francucci.
10 * All rights reserved. Protected by international copyright laws.
11 *
12 *
13 * RKH is free software: you can redistribute it and/or modify it under the
14 * terms of the GNU General Public License as published by the Free Software
15 * Foundation, either version 3 of the License, or (at your option) any
16 * later version.
17 *
18 * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with RKH, see copying.txt file.
25 *
26 * Contact information:
27 * RKH site: http://vortexmakes.com/que-es/
28 * RKH GitHub: https://github.com/vortexmakes/RKH
29 * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30 * e-mail: lf@vortexmakes.com
31 * ---------------------------------------------------------------------------
32 */
33
47/* -------------------------- Development history -------------------------- */
48/*
49 * 2017.17.05 LeFr v2.4.05 Initial version
50 */
51
52/* -------------------------------- Authors -------------------------------- */
53/*
54 * LeFr Leandro Francucci lf@vortexmakes.com
55 */
56
57/* --------------------------------- Notes --------------------------------- */
58/* --------------------------------- Module -------------------------------- */
59#ifndef __RKHQUEUE_H__
60#define __RKHQUEUE_H__
61
62/* ----------------------------- Include files ----------------------------- */
63#include "rkhcfg.h"
64#include "rkhtype.h"
65
66/* ---------------------- External C language linkage ---------------------- */
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71/* --------------------------------- Macros -------------------------------- */
83#define RKH_QUEUE_IS_EMPTY(q) \
84 (rbool_t)(rkh_queue_get_num((RKH_QUEUE_T *)(q)) == 0)
85
86/* -------------------------------- Constants ------------------------------ */
106
107/* ------------------------------- Data types ------------------------------ */
116#if RKH_CFG_QUE_SIZEOF_NELEM == 8
117typedef rui8_t RKH_QUENE_T;
118#elif RKH_CFG_QUE_SIZEOF_NELEM == 16
119typedef rui16_t RKH_QUENE_T;
120#elif RKH_CFG_QUE_SIZEOF_NELEM == 32
121typedef rui32_t RKH_QUENE_T;
122#else
123typedef rui8_t RKH_QUENE_T;
124#endif
125
130typedef enum
131{
132 RKH_QUE_OK, RKH_QUE_EMPTY, RKH_QUE_FULL
134
146typedef struct RKH_QINFO_T
147{
148 rui16_t nputs; /* # of put requests */
149 rui16_t ngets; /* # of get requests */
150 rui16_t nreads; /* # of queue read requests */
151 rui16_t nempty; /* # of queue empty retrieves */
152 rui16_t nfull; /* # of queue full retrieves */
153} RKH_QUEI_T;
154
189typedef struct RKH_QUEUE_T
190{
196
202
207 void **pout;
208
213 void **pin;
214
219 const void **pstart;
220
225 void **pend;
226
235 const struct RKH_SMA_T *sma;
236
244#if RKH_CFG_QUE_GET_LWMARK_EN == RKH_ENABLED
245 RKH_QUENE_T nmin;
246#endif
247
253#if RKH_CFG_QUE_GET_INFO_EN == RKH_ENABLED
254 RKH_QUEI_T rqi;
255#endif
256
268
269/* -------------------------- External variables --------------------------- */
270/* -------------------------- Function prototypes -------------------------- */
299void rkh_queue_init(RKH_QUEUE_T* q, const void** sstart, RKH_QUENE_T ssize,
300 void* sma);
301
318
332
352
372
390void rkh_queue_put_fifo(RKH_QUEUE_T *q, const void *pe);
391
412void rkh_queue_put_lifo(RKH_QUEUE_T *q, const void *pe);
413
436
456ruint rkh_queue_read(RKH_QUEUE_T *q, void *pe);
457
482
496
513
514/* -------------------- External C language linkage end -------------------- */
515#ifdef __cplusplus
516}
517#endif
518
519/* ------------------------------ Module end ------------------------------- */
520#endif
521
522/* ------------------------------ End of file ------------------------------ */
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....
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.
ruint rkh_queue_read(RKH_QUEUE_T *q, void *pe)
Read an element from a queue without remove it.
void rkh_queue_deplete(RKH_QUEUE_T *q)
Depletes a queue. Empties the contents of the queue and eliminates all stored elements.
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.
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.
RKH_QUENE_T rkh_queue_get_num(RKH_QUEUE_T *q)
Returns the number of elements currently in the queue.
void rkh_queue_clear_info(RKH_QUEUE_T *q)
Clear performance information for a particular queue.
void rkh_queue_get_info(RKH_QUEUE_T *q, RKH_QUEI_T *pqi)
Retrieves performance information for a particular queue.
RKH user configurations.
RKHQueueType
Queue types.
Definition rkhqueue.h:94
@ PriorityQueType
Definition rkhqueue.h:104
@ RegularQueType
Definition rkhqueue.h:98
RKH_QUECODE_T
Return codes from queue operations.
Definition rkhqueue.h:131
rui8_t RKH_QUENE_T
This data type defines the maximum number of elements that any queue can contain.
Definition rkhqueue.h:123
void rkh_queue_setType(RKH_QUEUE_T *q, RKHQueueType type)
Sets the type of the queue.
Defines the data types that uses RKH.
Defines the data structure into which the performance information for queues is stored.
Definition rkhqueue.h:147
Defines the data structure used to maintain information about the queue.
Definition rkhqueue.h:190
RKH_QUENE_T nelems
Number of elements.
Definition rkhqueue.h:195
void ** pend
Points to the end of the queue storage area.
Definition rkhqueue.h:225
RKHQueueType type
Minimum number of free elements ever in this queue.
Definition rkhqueue.h:266
void ** pout
Points to the free next place in the storage area.
Definition rkhqueue.h:207
const struct RKH_SMA_T * sma
Points to the associated SMA (a.k.a Active Object) that receives the enqueued events.
Definition rkhqueue.h:235
const void ** pstart
Points to beginning of the queue storage area.
Definition rkhqueue.h:219
void ** pin
Points to the next place of queued item.
Definition rkhqueue.h:213
RKH_QUENE_T qty
Number of elements currently in the queue.
Definition rkhqueue.h:201
Describes the SMA (active object in UML).
Definition rkhsma.h:772