SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
|
Unified queue item supporting both messages and function tasks. More...
#include <EventQueue.h>
Public Member Functions | |
QueueItem (std::shared_ptr< Message > msg, int64_t when) | |
Constructor for message queue items. | |
QueueItem (std::packaged_task< void()> &&t, int64_t when) | |
Constructor for function queue items. | |
QueueItem (QueueItem &&other) noexcept | |
Move constructor - transfers ownership of queue item. | |
QueueItem & | operator= (QueueItem &&other) noexcept |
Move assignment operator - transfers ownership. | |
QueueItem (const QueueItem &)=delete | |
Copy constructor - deleted (move-only semantics) | |
QueueItem & | operator= (const QueueItem &)=delete |
Copy assignment - deleted (move-only semantics) | |
Public Attributes | |
QueueItemType | type |
Type discriminator for queue item. | |
int64_t | whenUs |
Execution time in microseconds (absolute) | |
std::shared_ptr< Message > | message |
Message payload (for MESSAGE type) | |
std::packaged_task< void()> | task |
Function task (for FUNCTION type) | |
Unified queue item supporting both messages and function tasks.
QueueItem provides a variant-like structure that can hold either traditional messages or modern function tasks while maintaining uniform timing and ordering semantics. Uses move-only semantics for optimal performance with function objects.
Key design principles:
Definition at line 115 of file EventQueue.h.
|
inline |
Constructor for message queue items.
msg | Shared pointer to message object |
when | Absolute execution time in microseconds |
Creates a queue item containing a traditional message for handler-based processing with specified execution timing.
Definition at line 130 of file EventQueue.h.
|
inline |
Constructor for function queue items.
t | Packaged task to execute (moved) |
when | Absolute execution time in microseconds |
Creates a queue item containing a function task for direct execution with specified timing.
Definition at line 141 of file EventQueue.h.
|
inlinenoexcept |
Move constructor - transfers ownership of queue item.
other | Queue item to move from |
Efficiently transfers ownership of either message or task without copying expensive function objects.
Definition at line 151 of file EventQueue.h.
|
delete |
Copy constructor - deleted (move-only semantics)
Queue items cannot be copied to prevent expensive function object duplication and ensure unique ownership.
Copy assignment - deleted (move-only semantics)
Queue items cannot be copy-assigned to maintain move-only semantics and prevent accidental expensive copies.
std::shared_ptr<Message> swt::EventQueue::QueueItem::message |
Message payload (for MESSAGE type)
Definition at line 119 of file EventQueue.h.
Referenced by operator=().
std::packaged_task<void()> swt::EventQueue::QueueItem::task |
Function task (for FUNCTION type)
Definition at line 120 of file EventQueue.h.
Referenced by operator=().
QueueItemType swt::EventQueue::QueueItem::type |
Type discriminator for queue item.
Definition at line 116 of file EventQueue.h.
Referenced by operator=().
int64_t swt::EventQueue::QueueItem::whenUs |
Execution time in microseconds (absolute)
Definition at line 117 of file EventQueue.h.
Referenced by operator=().