| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // Author: Sychov. A / 12/2020
- #ifndef QUEUE_EX_H
- #define QUEUE_EX_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "app/queue/queue.h"
- ///
- /// \brief Initialize a queue linking the user buffer
- /// \param self Pointer to the queue.
- /// \param buffer Pointer to the user buffer to be used as storage
- /// \param capacity Capacity of the user buffer storage
- /// \return QUEUE_RC_NOERROR if no error or error code.
- ///
- static inline int queue_init(queue_t * self, void * buffer, int16_t capacity )
- {
- if( RINGBUF_RC_NO_ERROR == ringbuf_init( self, buffer, capacity ) )
- {
- return QUEUE_RC_NOERROR;
- }
- return QUEUE_RC_INIT_ERROR;
- }
- ///
- /// \brief Placing a dummy record to the end of the queue with specified size
- /// \param self Pointer to the queue.
- /// \param record Pointer to the record struct to place.
- /// \param payload Pointer to the trailing data payload following the record struct
- /// \details The record struct must specify the whole record size including the payload size
- /// in @record.size, while the @record.payload must specify only the payload size (@payload)
- /// \return QUEUE_RC_NOERROR if no error or error code.
- ///
- int queue_pushback_payload(queue_t * self, queue_record_t * record, const void * payload );
- ///
- /// \brief Getting a part of record with the payload from the queue without extracting.
- /// \param self Pointer to the record queue.
- /// \param record Pointer to the record to store.
- /// \param recordBufferSize Size of the struct to store a part of record (minimum is sizeof(record))
- /// \param payload Pointer to the payload to store.
- /// \param payloadBufferSize Size of the buffer to store a part of payload.
- /// \return Size of the peeked record on success, error code otherwise.
- ///
- int queue_peek_payload(const queue_t * self, queue_record_t * record, int16_t recordBufferSize, void * payload, int16_t payloadBufferSize );
- ///
- /// \brief Getting a part of record from the queue without extracting.
- /// \param self Pointer to the record queue.
- /// \param record Pointer to the record to store.
- /// \param size Size of the struct to store a part of record.
- /// \return Size of the peeked record on success, error code otherwise.
- ///
- int queue_peek_n(const queue_t * self, queue_record_t * record, int16_t partSize);
- #ifdef __cplusplus
- }
- #endif
- #endif // QUEUE_EX_H
|