#ifndef INCLUDED_C_LOCKQUEUE_H #define INCLUDED_C_LOCKQUEUE_H #ifndef INCLUDED_C_TYPES_H #include #endif /*INCLUDED_C_TYPES_H*/ #ifndef INCLUDED_C_MUTEX_H #include #endif /*INCLUDED_C_MUTEX_H*/ #ifndef INCLUDED_C_COND_H #include #endif /*INCLUDED_C_COND_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { void** data; c_size_t capacity; c_size_t write_idx; c_size_t read_idx; c_size_t size; c_bool_t is_shutdown; c_Mutex_t lock; c_Cond_t not_full; c_Cond_t not_empty; }c_LockQueue_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_err_t c_LockQueue_Init(c_LockQueue_t* queue, c_size_t capacity); void c_LockQueue_Destroy(c_LockQueue_t* queue); void c_LockQueue_Shutdown(c_LockQueue_t* queue); c_err_t c_LockQueue_Push(c_LockQueue_t* queue, void* data); c_err_t c_LockQueue_Pop(c_LockQueue_t* queue, void** data); c_bool_t c_LockQueue_TimedPop(c_LockQueue_t* queue, void** item, c_uint_t timeout_ms); c_bool_t c_LockQueue_TimedPush(c_LockQueue_t* queue, void* item, c_uint_t timeout_ms); c_size_t c_LockQueue_Size(c_LockQueue_t* queue); c_bool_t c_LockQueue_IsEmpty(c_LockQueue_t* queue); c_bool_t c_LockQueue_IsFull(c_LockQueue_t* queue); #endif /*INCLUDED_C_LOCKQUEUE_H*/