Interface against a message queue.
More...
#include <ibusmessagequeue.h>
|
virtual | ~IBusMessageQueue () |
| Destructor.
|
void | Push (const std::shared_ptr< IBusMessage > &message) |
| Adds a message to the end of the queue.
|
void | Push (const std::vector< uint8_t > &message_buffer) |
| Adds a serialized message to the queue.
|
void | PushFront (const std::shared_ptr< IBusMessage > &message) |
| Adds a message first in the queue.
|
std::shared_ptr< IBusMessage > | Pop () |
| Extract a message from the front of the queue.
|
template<class Rep, class Period> |
std::shared_ptr< IBusMessage > | PopWait (const std::chrono::duration< Rep, Period > &rel_time) |
| Blocks a period if queue is empty otherwise returning a message.
|
size_t | MessageSize () const |
| Retuns the size of next message.
|
size_t | Size () const |
| Retuns the number messages in the queue.
|
bool | Empty () const |
| Returns true if the queue is empty.
|
template<class Rep, class Period> |
void | EmptyWait (const std::chrono::duration< Rep, Period > &rel_time) |
| Waits a period or direct if the queue not is empty.
|
virtual void | Start () |
| Initialize the queue.
|
virtual void | Stop () |
| Stops the queue.
|
void | Clear () |
| Removes all messages in the queue.
|
The class defines a generic interface against a message queue. The queue stores messages in primary memory, The queue is thread-safe. The user application only use one end of the queue while the broker uses the other end. The actual implementation of the queue is dependent on the type of broker.
◆ Empty()
bool bus::IBusMessageQueue::Empty |
( |
| ) |
const |
|
nodiscard |
- Returns
- True if the queue doesn't have any messages.
◆ EmptyWait()
template<class Rep, class Period>
void bus::IBusMessageQueue::EmptyWait |
( |
const std::chrono::duration< Rep, Period > & | rel_time | ) |
|
- Template Parameters
-
Rep | See std::chrono_utils. |
Period | See std::chrono_utils. |
- Parameters
-
◆ MessageSize()
size_t bus::IBusMessageQueue::MessageSize |
( |
| ) |
const |
|
nodiscard |
- Returns
- The next message size.
◆ Pop()
std::shared_ptr< IBusMessage > bus::IBusMessageQueue::Pop |
( |
| ) |
|
Returns the next message in the queue. Note that if the queue is empty, the smart pointer may be empty.
- Returns
- Smart pointer to a message.
◆ PopWait()
template<class Rep, class Period>
std::shared_ptr< IBusMessage > bus::IBusMessageQueue::PopWait |
( |
const std::chrono::duration< Rep, Period > & | rel_time | ) |
|
- Template Parameters
-
Rep | Type of clock |
Period | Duration |
- Parameters
-
rel_time | Time period to wait. Use std::chrono_utils. |
- Returns
- Return the next message or an empty message.
◆ Push() [1/2]
void bus::IBusMessageQueue::Push |
( |
const std::shared_ptr< IBusMessage > & | message | ) |
|
- Parameters
-
message | Smart pointer to the message. |
◆ Push() [2/2]
void bus::IBusMessageQueue::Push |
( |
const std::vector< uint8_t > & | message_buffer | ) |
|
Adds aserialized message to the end of the queue. The function deserialize the message first and adds it to the queue.
- Parameters
-
message_buffer | Serialized byte array. |
◆ PushFront()
void bus::IBusMessageQueue::PushFront |
( |
const std::shared_ptr< IBusMessage > & | message | ) |
|
Adds a message to the front of the queue. This happens in certain circumstances when the message cannot be sent due to not enogh room in the shared memory.
- Parameters
-
message | Smart pointer to a message. |
◆ Size()
size_t bus::IBusMessageQueue::Size |
( |
| ) |
const |
|
nodiscard |
- Returns
- Number of messages in the queue.
The documentation for this class was generated from the following file: