#include <queue.h>
Classes | |
struct | Element |
Public Member Functions | |
Queue (Queue &&other)=default | |
Queue & | operator= (Queue &&other)=default |
Element * | buf_addr () const noexcept |
Returns the address of the internal buffer. | |
size_t | size () const noexcept |
Returns the size of the internal buffer. | |
uint32_t | capacity () const noexcept |
Returns the capacity of the queue. | |
Static Public Member Functions | |
static std::unique_ptr< Subclass > | Create (const std::string &queue_name, size_t size=0, bool join_if_exists=true, std::string huge_page_prefix="") noexcept |
Factory method to create a Queue object. | |
Static Public Attributes | |
static constexpr size_t | kElementMetaSize = sizeof(T) + 8 |
static constexpr size_t | kElementPadding |
Protected Member Functions | |
Queue (const std::string &queue_name, size_t size, const std::string &huge_page_prefix) noexcept | |
int | Init (bool join_if_exists) noexcept |
Initializes the Queue object. | |
bool | created_queue () const noexcept |
uint32_t | index_mask () const noexcept |
Queue parent class.
Use this queue to communicate between different threads. It should be instantiated using either the QueueConsumer or QueueProducer classes through the Create method.
Example: // Producer. std::unique_ptr<QueueProducer<int>> queue_producer = QueueProducer<int>::Create("queue_name");
// Consumer. std::unique_ptr<QueueConsumer<int>> queue_consumer = QueueConsumer<int>::Create("queue_name");
queue_producer->Push(42);
int data = queue_consumer->Pop().value_or(-1); std::cout << data << std::endl; // Should print 42.
data = queue_consumer->Pop().value_or(-1); std::cout << data << std::endl; // Should print -1.
|
inlinenoexcept |
|
inlineexplicitprotectednoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestaticnoexcept |
Factory method to create a Queue object.
queue_name | Global queue name. |
size | Size of the queue (in bytes). If zero (default), the size will be inferred if the queue already exists and will be set to kBufPageSize otherwise. |
join_if_exists | If true (default), the queue will be joined if it already exists. If false, the creation will fail if the queue already exists. |
huge_page_prefix | Prefix to use when creating the shared memory file. If empty (default), the default prefix will be used. |
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inlinenoexcept |
|
staticconstexpr |
|
staticconstexpr |