CppCMS
|
This is a basic object that allows execution of asynchronous operations. More...
#include <booster/booster/aio/basic_io_device.h>
Public Member Functions | |
basic_io_device () | |
basic_io_device (io_service &srv) | |
virtual | ~basic_io_device () |
bool | has_io_service () |
io_service & | get_io_service () |
void | set_io_service (io_service &srv) |
void | reset_io_service () |
void | attach (native_type fd) |
void | assign (native_type fd) |
native_type | release () |
native_type | native () |
void | close () |
void | close (system::error_code &e) |
void | on_readable (event_handler const &r) |
void | on_writeable (event_handler const &r) |
void | cancel () |
basic_io_device & | lowest_layer () |
void | set_non_blocking (bool nonblocking) |
void | set_non_blocking (bool nonblocking, system::error_code &e) |
Static Public Member Functions | |
static bool | would_block (system::error_code const &e) |
Protected Member Functions | |
bool | dont_block (event_handler const &c) |
bool | dont_block (io_handler const &c) |
This is a basic object that allows execution of asynchronous operations.
It represents a generic "select"able file descriptor or SOCKET on Windows platform.
It does following:
Create a new device not attached to event loop
Create a new device that is attached to the event loop srv
virtual booster::aio::basic_io_device::~basic_io_device | ( | ) | [virtual] |
Destroy the object. If it owns the file descriptor or socket it closes it
void booster::aio::basic_io_device::assign | ( | native_type | fd | ) |
Assign existing file descriptor fd to the device. The ownership is transferred to the object
void booster::aio::basic_io_device::attach | ( | native_type | fd | ) |
Attach the file descriptor fd to the device. The ownership is not transferred to the object.
If basic_io_device owns other file descriptor, it is closed.
Cancel all asynchronous operations.
void booster::aio::basic_io_device::close | ( | ) |
Cancels all pending asynchronous events. If the ownership belongs to it closes the file descriptor.
Throws system::system_error if error occurs.
Cancels all pending asynchronous events. If the ownership belongs to it closes the file descriptor.
If a error occurs it is assigned to e.
bool booster::aio::basic_io_device::dont_block | ( | event_handler const & | c | ) | [protected] |
Set non-blocking mode. If error occurs returns false and the error is reported via callback c
bool booster::aio::basic_io_device::dont_block | ( | io_handler const & | c | ) | [protected] |
Set non-blocking mode. If error occurs returns false and the error is reported via callback c
Returns the connected io_service, throws system::system_error if no io_service connected
Check if the basic_io_device is connected to the io_service
Returns *this
Get the underlying file descriptor. Returns invalid_socket if the file descriptor was not assigned
void booster::aio::basic_io_device::on_readable | ( | event_handler const & | r | ) |
Start asynchronous polling for readability. The result is reported via callback r.
If io_service is not assigned throws system::system_error, all other errors reported via r.
void booster::aio::basic_io_device::on_writeable | ( | event_handler const & | r | ) |
Start asynchronous polling for writeability. The result is reported via callback r.
If io_service is not assigned throws system::system_error, all other errors reported via r.
Release the ownership on the current file descriptor. The user is responsible to close it.
Detaches the object from io_service. Cancels all pending asynchronous operations.
void booster::aio::basic_io_device::set_io_service | ( | io_service & | srv | ) |
Sets new io_service. Cancels all pending asynchronous operations on the connected io_service.
void booster::aio::basic_io_device::set_non_blocking | ( | bool | nonblocking | ) |
Set the object to blocking or non-blocking mode.
Throws system::system_error if error occurs.
void booster::aio::basic_io_device::set_non_blocking | ( | bool | nonblocking, |
system::error_code & | e | ||
) |
Set the object to blocking or non-blocking mode.
If a error occurs it is assigned to e.
static bool booster::aio::basic_io_device::would_block | ( | system::error_code const & | e | ) | [static] |
Check if a error code e reports that the non-blocking operation would block