Program Listing for File pcqueue.h
↰ Return to documentation for file (rcsw/multithread/pcqueue.h
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcsw/multithread/csem.h"
#include "rcsw/multithread/mutex.h"
#include "rcsw/ds/fifo.h"
/*******************************************************************************
* Structure Definitions
******************************************************************************/
#define pcqueue_params fifo_params
struct pcqueue {
struct fifo fifo;
struct mutex mutex;
struct csem slots_avail;
struct csem slots_inuse;
uint32_t flags;
};
/*******************************************************************************
* API Functions
******************************************************************************/
BEGIN_C_DECLS
static inline bool_t pcqueue_isfull(const struct pcqueue* const queue) {
RCSW_FPC_NV(false, NULL != queue);
return fifo_isfull(&queue->fifo);
}
static inline bool_t pcqueue_isempty(const struct pcqueue* const queue) {
RCSW_FPC_NV(false, NULL != queue);
return fifo_isempty(&queue->fifo);
}
static inline size_t pcqueue_size(const struct pcqueue* const queue) {
RCSW_FPC_NV(0, NULL != queue);
return fifo_size(&queue->fifo);
}
static inline size_t pcqueue_capacity(const struct pcqueue* const queue) {
RCSW_FPC_NV(0, NULL != queue);
return fifo_capacity(&queue->fifo);
}
static inline size_t pcqueue_n_free(const struct pcqueue* const queue) {
RCSW_FPC_NV(0, NULL != queue);
return pcqueue_capacity(queue) - pcqueue_size(queue);
}
RCSW_API struct pcqueue * pcqueue_init(struct pcqueue *pcqueue_in,
const struct pcqueue_params * params) RCSW_WUR;
RCSW_API void pcqueue_destroy(struct pcqueue * pcqueue);
RCSW_API status_t pcqueue_push(struct pcqueue * pcqueue, const void * e);
RCSW_API status_t pcqueue_pop(struct pcqueue * pcqueue, void * e);
RCSW_API status_t pcqueue_timedpop(struct pcqueue * pcqueue,
const struct timespec * to,
void * e);
RCSW_API status_t pcqueue_timedpeek(struct pcqueue* const queue,
const struct timespec* const to,
void** const e);
RCSW_API status_t pcqueue_peek(struct pcqueue* const queue, void** const e);
END_C_DECLS