#ifndef _PreAllocBufferPriorityQueue_H_ #define _PreAllocBufferPriorityQueue_H_ #include #include #include class PreAllocBufferPriorityQueue { public: struct Config { bool multithreadSafe; bool fullQueueDropFront; bool fullQueueSync; size_t count; size_t maxBuffSize; Config() : multithreadSafe(false), fullQueueDropFront(false), fullQueueSync(false), count(0), maxBuffSize(0) { } }; struct Buffer { uint8_t* buffer; size_t buffSize; Buffer() : buffer(nullptr), buffSize(0) { } }; PreAllocBufferPriorityQueue(const Config& _cfg); ~PreAllocBufferPriorityQueue(); Buffer* Seek(); Buffer* Dequeue(); void Release(Buffer* buffer); Buffer* Enqueue(); bool Empty() const; bool Full() const; private: const Config cfg; void* mtsMux; typedef std::vector buffers_vec_t; buffers_vec_t allBuffers; buffers_vec_t freeBuffers; typedef std::list buffers_lst_t; buffers_lst_t usedBuffers; }; #endif