Renesas PTX1xxR IoT-Reader API Version 7.3.1
Renesas Software Stack for IoT-Reader Applications
ptxBufferPool.h
Go to the documentation of this file.
1
43#ifndef PTXBUFFERPOOL_H
44#define PTXBUFFERPOOL_H
45
69/*
70 * ####################################################################################################################
71 * INCLUDES
72 * ####################################################################################################################
73 */
74
75#include "ptx_Status.h"
76#include "ptxOsal.h"
77#include "ptxLog.h"
78
79#ifdef __cplusplus
80extern "C" {
81#endif
82
83/*
84 * ####################################################################################################################
85 * DEFINES / TYPES / INTERNALS
86 * ####################################################################################################################
87 */
88
93{
94 ptxBufferPool_ItemState_IDLE,
95 ptxBufferPool_ItemState_ACTIVE,
96 ptxBufferPool_ItemState_IN_USE,
97 ptxBufferPool_ItemState_MAX_COUNT
99
100/*
101 * Forward declaration
102 */
103struct ptxBufferPool;
104
124
132typedef struct ptxBufferPool
133{
134 /* Administrative.*/
137 uint8_t LogDetails;
138 struct ptxOsal *OS;
141 /* Buffer of items */
143 size_t NumItems;
145 /* Handling memory. */
146 uint8_t *MemSpace;
147 size_t MemSize;
150
151
152/*
153 * ####################################################################################################################
154 * API FUNCTIONS
155 * ####################################################################################################################
156 */
157
173ptxStatus_t ptxBufferPool_Init(ptxBufferPool_t *bufPool, struct ptxOsal *osAl, ptxLog_t *logCtx, size_t maxNumBuffers, size_t memSize, uint8_t logDetails);
174
186
200
212
224
239
255
267
279
291
292#ifdef __cplusplus
293}
294#endif
295
298#endif /* Guard */
299
300
ptxStatus_t ptxBufferPool_ReleaseItem(ptxBufferPool_Item_t *poolItem)
Release an item and allow it to be garbage-collected.
ptxStatus_t ptxBufferPool_DeInit(ptxBufferPool_t *bufPool)
De-initialize the component, release all resources.
ptxStatus_t ptxBufferPool_ProvideItem(ptxBufferPool_t *bufPool, ptxBufferPool_Item_t **poolItem, size_t sizeReq)
Provide a buffer that is currently not in use. Wait for a buffer to become free if there is currently...
ptxStatus_t ptxBufferPool_ReleaseUnusedItem(ptxBufferPool_Item_t *poolItem)
Mark an unused buffer disposable.
ptxStatus_t ptxBufferPool_ClaimItem(ptxBufferPool_Item_t *poolItem)
Claim an item to prevent it from being garbage-collected.
size_t * ptxBufferPool_PointToLength(ptxBufferPool_Item_t *poolItem)
Get the current buffer length pointer.
size_t ptxBufferPool_GetLength(ptxBufferPool_Item_t *poolItem)
Get the buffer length.
ptxStatus_t ptxBufferPool_Init(ptxBufferPool_t *bufPool, struct ptxOsal *osAl, ptxLog_t *logCtx, size_t maxNumBuffers, size_t memSize, uint8_t logDetails)
Initialize the buffer pool. Allocate a number of buffers.
ptxStatus_t ptxBufferPool_ProvideAndClaimItem(ptxBufferPool_t *bufPool, ptxBufferPool_Item_t **poolItem, size_t sizeReq)
Combines the two functions Provide() and Claim().
uint8_t * ptxBufferPool_GetBuffer(ptxBufferPool_Item_t *poolItem)
Get the buffer.
struct ptxBufferPool_Item ptxBufferPool_Item_t
Buffer Pool Item structure.
struct ptxBufferPool ptxBufferPool_t
Buffer Pool structure.
enum ptxBufferPool_ItemState ptxBufferPool_ItemState_t
ptxBufferPool_ItemState
Definition ptxBufferPool.h:93
uint16_t ptxStatus_t
Status Type.
Definition ptx_Status.h:82
struct ptxMutex * ptxMutex_t
Mutex Wrapper Structure - Forward Declaration.
Definition ptxOsal.h:95
struct ptxSemaphore * ptxSemaphore_t
Semaphore Wrapper Structure - Forward Declaration.
Definition ptxOsal.h:100
Buffer Pool Item structure.
Definition ptxBufferPool.h:114
uint8_t Number
Definition ptxBufferPool.h:116
size_t StartingIndex
Definition ptxBufferPool.h:119
struct ptxBufferPool_Item * NextBufferItem
Definition ptxBufferPool.h:121
ptxMutex_t * Mx
Definition ptxBufferPool.h:117
ptxBufferPool_ItemState_t State
Definition ptxBufferPool.h:115
struct ptxBufferPool * BufferPool
Definition ptxBufferPool.h:118
struct ptxBufferPool_Item * PrevBufferItem
Definition ptxBufferPool.h:122
size_t Length
Definition ptxBufferPool.h:120
Buffer Pool structure.
Definition ptxBufferPool.h:133
ptxMutex_t Mx
Definition ptxBufferPool.h:135
ptxSemaphore_t Sem
Definition ptxBufferPool.h:136
ptxLog_t * LOG
Definition ptxBufferPool.h:139
size_t NumItems
Definition ptxBufferPool.h:143
size_t MemSize
Definition ptxBufferPool.h:147
uint8_t LogDetails
Definition ptxBufferPool.h:137
ptxBufferPool_Item_t * Items
Definition ptxBufferPool.h:142
ptxBufferPool_Item_t * ListItems
Definition ptxBufferPool.h:148
uint8_t * MemSpace
Definition ptxBufferPool.h:146
struct ptxOsal * OS
Definition ptxBufferPool.h:138
Logger Component Structure.
Definition ptxLog.h:208