KrisLibrary
1.0.0
|
Asynchronous reader with queue. More...
#include <AsyncIO.h>
Public Member Functions | |
AsyncReaderQueue (size_t queueMax=1000) | |
This will keep only the newest queueMax messages. | |
void | OnRead (const std::string &msg) |
Called by subclass to add a message onto the queue. | |
void | OnRead_NoLock (const std::string &msg) |
virtual void | Reset () |
Resets the queue and history. | |
virtual void | Work () |
Do some work to read messages from sender – must be done by subclass. | |
int | MessageCount () |
int | UnreadCount () |
std::string | PeekNewest () |
std::string | Newest () |
std::vector< std::string > | New () |
Public Attributes | |
Mutex | mutex |
size_t | queueMax |
size_t | msgCount |
std::string | msgLast |
std::list< std::string > | msgQueue |
size_t | numDroppedMsgs |
Asynchronous reader with queue.
Stores the last message and the newest queueMax messages from some other process / subclass.
Usage is to call Newest() or New() to get the latest message(s). These will flush the queue.
To do a non-blocking check for new messages without flushing the queue, call UnreadCount(). To peek to the latest, call PeekLast()