KrisLibrary
1.0.0
|
Asynchronous writer with queue. More...
#include <AsyncIO.h>
Public Member Functions | |
AsyncWriterQueue (size_t queueMax=1000) | |
bool | WriteAvailable () const |
Called by subclass to see whether there's a message to send. | |
std::string | OnWrite () |
Called by subclass to get the next message to deliver to the destination. | |
std::string | OnWrite_NoLock () |
virtual void | Reset () |
Resets the queue and history. | |
virtual void | Work () |
Do some work to write messages to receiver – must be done by subclass. | |
void | Send (const std::string &msg) |
int | SentCount () |
int | DeliveredCount () |
Public Attributes | |
Mutex | mutex |
size_t | queueMax |
size_t | msgCount |
std::list< std::string > | msgQueue |
size_t | numDroppedMsgs |
Asynchronous writer with queue.
Sends the latest queueMax messages.
The usage is to call SendMessage(). The writer will then somehow send it to a receiver (as implemented by the subclass or some external monitor).
AsyncWriterQueue::AsyncWriterQueue | ( | size_t | queueMax = 1000 | ) |
This will keep only the newest recvQueueMax messages sent, and will only allow an overflow of sendQueueMax messages. Typical usage may be 1 and 1 (only keep and send newest messages).