KrisLibrary  1.0.0
Public Member Functions | Public Attributes | List of all members
AsyncReaderThread Class Reference

An asynchronous reader that uses multithreading. User/subclass will initialize the transport protocol (usually blocking I/O) by setting the transport member. More...

#include <AsyncIO.h>

Inheritance diagram for AsyncReaderThread:
AsyncReaderQueue SocketReadWorker

Public Member Functions

 AsyncReaderThread (double timeout=Math::Inf)
 
virtual void Reset ()
 Resets the queue and history.
 
virtual void Work ()
 Do some work to read messages from sender – must be done by subclass.
 
virtual bool Start ()
 Subclasses: override these to implement custom starting and stopping routines.
 
virtual void Stop ()
 
- Public Member Functions inherited from AsyncReaderQueue
 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)
 
int MessageCount ()
 
int UnreadCount ()
 
std::string PeekNewest ()
 
std::string Newest ()
 
std::vector< std::string > New ()
 

Public Attributes

std::unique_ptr< TransportBasetransport
 
bool initialized
 
Thread thread
 
double timeout
 
Timer timer
 
double lastReadTime
 
- Public Attributes inherited from AsyncReaderQueue
Mutex mutex
 
size_t queueMax
 
size_t msgCount
 
std::string msgLast
 
std::list< std::string > msgQueue
 
size_t numDroppedMsgs
 

Detailed Description

An asynchronous reader that uses multithreading. User/subclass will initialize the transport protocol (usually blocking I/O) by setting the transport member.

If no read has occurred for 'timeout' seconds, then the thread will quit

Stop() or destructor will quit the read thread.


The documentation for this class was generated from the following files: