Handles Asynchronous I/O reading and writing. More...
#include <async_worker.h>
Public Types | |
typedef boost::mutex | Mutex |
typedef boost::mutex::scoped_lock | ScopedLock |
Public Types inherited from ublox_gps::Worker | |
typedef boost::function< void(unsigned char *, std::size_t &)> | Callback |
Public Member Functions | |
AsyncWorker (boost::shared_ptr< StreamT > stream, boost::shared_ptr< boost::asio::io_service > io_service, std::size_t buffer_size=8192) | |
Construct an Asynchronous I/O worker. More... | |
bool | isOpen () const |
Whether or not the I/O stream is open. More... | |
bool | send (const unsigned char *data, const unsigned int size) |
Send the data bytes via the I/O stream. More... | |
void | setCallback (const Callback &callback) |
Set the callback function which handles input messages. More... | |
void | setRawDataCallback (const Callback &callback) |
Set the callback function which handles raw data. More... | |
void | wait (const boost::posix_time::time_duration &timeout) |
Wait for incoming messages. More... | |
virtual | ~AsyncWorker () |
Public Member Functions inherited from ublox_gps::Worker | |
virtual | ~Worker () |
Protected Member Functions | |
void | doClose () |
Close the I/O stream. More... | |
void | doRead () |
Read the input stream. More... | |
void | doWrite () |
Send all the data in the output buffer. More... | |
void | readEnd (const boost::system::error_code &, std::size_t) |
Process messages read from the input stream. More... | |
Protected Attributes | |
boost::shared_ptr< boost::thread > | background_thread_ |
std::vector< unsigned char > | in_ |
The input buffer. More... | |
std::size_t | in_buffer_size_ |
boost::shared_ptr< boost::asio::io_service > | io_service_ |
The I/O service. More... | |
std::vector< unsigned char > | out_ |
The output buffer. More... | |
Callback | read_callback_ |
Callback function to handle received messages. More... | |
boost::condition | read_condition_ |
Mutex | read_mutex_ |
Lock for the input buffer. More... | |
bool | stopping_ |
Whether or not the I/O service is closed. More... | |
boost::shared_ptr< StreamT > | stream_ |
The I/O stream. More... | |
Callback | write_callback_ |
Callback function to handle raw data. More... | |
boost::condition | write_condition_ |
Mutex | write_mutex_ |
Lock for the output buffer. More... | |
Handles Asynchronous I/O reading and writing.
Definition at line 51 of file async_worker.h.
typedef boost::mutex ublox_gps::AsyncWorker< StreamT >::Mutex |
Definition at line 53 of file async_worker.h.
typedef boost::mutex::scoped_lock ublox_gps::AsyncWorker< StreamT >::ScopedLock |
Definition at line 54 of file async_worker.h.
ublox_gps::AsyncWorker< StreamT >::AsyncWorker | ( | boost::shared_ptr< StreamT > | stream, |
boost::shared_ptr< boost::asio::io_service > | io_service, | ||
std::size_t | buffer_size = 8192 |
||
) |
Construct an Asynchronous I/O worker.
stream | the stream for th I/O service |
io_service | the I/O service |
buffer_size | the size of the input and output buffers |
Definition at line 138 of file async_worker.h.
|
virtual |
Definition at line 155 of file async_worker.h.
|
protected |
Close the I/O stream.
Definition at line 252 of file async_worker.h.
|
protected |
Read the input stream.
Definition at line 204 of file async_worker.h.
|
protected |
Send all the data in the output buffer.
Definition at line 181 of file async_worker.h.
|
inlinevirtual |
Whether or not the I/O stream is open.
Implements ublox_gps::Worker.
Definition at line 91 of file async_worker.h.
|
protected |
Process messages read from the input stream.
error_code | an error code for read failures |
the | number of bytes received |
Definition at line 215 of file async_worker.h.
|
virtual |
Send the data bytes via the I/O stream.
data | the buffer of data bytes to send |
size | the size of the buffer |
Implements ublox_gps::Worker.
Definition at line 162 of file async_worker.h.
|
inlinevirtual |
Set the callback function which handles input messages.
callback | the read callback which handles received messages |
Implements ublox_gps::Worker.
Definition at line 71 of file async_worker.h.
|
inlinevirtual |
Set the callback function which handles raw data.
callback | the write callback which handles raw data |
Implements ublox_gps::Worker.
Definition at line 77 of file async_worker.h.
|
virtual |
Wait for incoming messages.
timeout | the maximum time to wait |
Implements ublox_gps::Worker.
Definition at line 263 of file async_worker.h.
|
protected |
thread for the I/O service
Definition at line 129 of file async_worker.h.
|
protected |
The input buffer.
Definition at line 121 of file async_worker.h.
|
protected |
number of bytes currently in the input buffer
Definition at line 122 of file async_worker.h.
|
protected |
The I/O service.
Definition at line 117 of file async_worker.h.
|
protected |
The output buffer.
Definition at line 127 of file async_worker.h.
|
protected |
Callback function to handle received messages.
Definition at line 131 of file async_worker.h.
|
protected |
Definition at line 120 of file async_worker.h.
|
protected |
Lock for the input buffer.
Definition at line 119 of file async_worker.h.
|
protected |
Whether or not the I/O service is closed.
Definition at line 134 of file async_worker.h.
|
protected |
The I/O stream.
Definition at line 116 of file async_worker.h.
|
protected |
Callback function to handle raw data.
Definition at line 132 of file async_worker.h.
|
protected |
Definition at line 126 of file async_worker.h.
|
protected |
Lock for the output buffer.
Definition at line 125 of file async_worker.h.