KrisLibrary
1.0.0
|
An synchronous reader/writer. User/subclass will initialize the transport protocol (usually blocking I/O) by setting the transport member. More...
#include <AsyncIO.h>
Public Member Functions | |
virtual void | Reset () |
virtual void | Work () |
virtual bool | Start () |
Subclasses: override these to implement custom starting and stopping routines. | |
virtual void | Stop () |
bool | Connected () |
bool | WriteReady () |
bool | ReadReady () |
Public Member Functions inherited from AsyncPipeQueue | |
AsyncPipeQueue (size_t recvQueueSize=1000, size_t writeQueueSize=1000) | |
void | OnRead (const std::string &msg) |
void | OnRead_NoLock (const std::string &msg) |
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 send to the destination. | |
std::string | OnWrite_NoLock () |
int | MessageCount () |
Receive functions. | |
int | UnreadCount () |
std::string | PeekNewest () |
std::vector< std::string > | New () |
std::string | Newest () |
void | Send (const std::string &msg) |
Send functions. | |
int | SentCount () |
int | DeliveredCount () |
Public Attributes | |
std::unique_ptr< TransportBase > | transport |
bool | initialized |
Timer | timer |
double | lastReadTime |
double | lastWriteTime |
Public Attributes inherited from AsyncPipeQueue | |
AsyncReaderQueue | reader |
AsyncWriterQueue | writer |
An synchronous reader/writer. User/subclass will initialize the transport protocol (usually blocking I/O) by setting the transport member.
User will call a work loop: pipe.Start(); while(not done) pipe.Work(); pipe.Stop();
The read / write queues are asynchronous so it is safe to call SendMessage, NewestMessage, NewMessages from another thread.