CppCMS
Public Member Functions | Static Public Member Functions | Protected Member Functions
booster::aio::basic_io_device Class Reference

This is a basic object that allows execution of asynchronous operations. More...

#include <booster/booster/aio/basic_io_device.h>

Inheritance diagram for booster::aio::basic_io_device:
booster::noncopyable booster::aio::basic_socket booster::aio::acceptor booster::aio::stream_socket

List of all members.

Public Member Functions

 basic_io_device ()
 basic_io_device (io_service &srv)
virtual ~basic_io_device ()
bool has_io_service ()
io_serviceget_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_devicelowest_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)

Detailed Description

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:


Constructor & Destructor Documentation

booster::aio::basic_io_device::basic_io_device ( )

Create a new device not attached to event loop

booster::aio::basic_io_device::basic_io_device ( io_service srv)

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


Member Function Documentation

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.

void booster::aio::basic_io_device::cancel ( )

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.

void booster::aio::basic_io_device::close ( system::error_code e)

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

io_service& booster::aio::basic_io_device::get_io_service ( )

Returns the connected io_service, throws system::system_error if no io_service connected

bool booster::aio::basic_io_device::has_io_service ( )

Check if the basic_io_device is connected to the io_service

basic_io_device& booster::aio::basic_io_device::lowest_layer ( )

Returns *this

native_type booster::aio::basic_io_device::native ( )

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.

native_type booster::aio::basic_io_device::release ( )

Release the ownership on the current file descriptor. The user is responsible to close it.

Note:
it just changes the "ownership" flag in the object, nothing else is done
void booster::aio::basic_io_device::reset_io_service ( )

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


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