ioxx Namespace Reference

Asynchronous I/O for C++. More...

Classes

class  acceptor
 Accept incoming stream connections on a local network port. More...
class  core
 Asynchronous interface to socket I/O, time events, and DNS. More...
class  system_error
 Base exception class for all operating system errors. More...
class  signal_block
 Block all POSIX signals for the current scope. More...
class  system_socket
 Primary interface to system sockets. More...

Typedefs

typedef unsigned int seconds_t
 An (unsigned) quantity of seconds.
typedef ::iovec iovec
 The native type used for scatter/gather I/O.
typedef int native_socket_t
 The system's native socket type.
typedef std::time_t time_t
 The current time of day, represented in seconds since 1970-01-01 00:00:00 UTC.
typedef ::timeval timeval
 The current time of day in microseconds since 1970-01-01 00:00:00 UTC.

Functions

template<class Result , class Predicate , class Action >
Result throw_errno_if (Predicate is_failure, std::string const &error_msg, Action f)
 Safety-wrapper for calling POSIX system functions.
template<class Predicate , class Action >
Action::result_type throw_errno_if (Predicate const &is_failure, std::string const &error_msg, Action const &f)
 Overloaded variant that automatically deduces the return type.
template<class Num , class Action >
Num throw_errno_if_minus1 (std::string const &error_msg, Action const &f)
 Specialized version of throw_errno_if() for system calls that return -1 on error.
template<class Action >
Action::result_type throw_errno_if_minus1 (std::string const &error_msg, Action const &f)
 Overloaded variant that automatically deduces the return type.
void reset (iovec &iov, char const *b, char const *e)
 Set an iovec to the given byte range.
iovec make_iovec (char const *b, char const *e)
 Construct ioxx::iovec using an iterator range.

Detailed Description

Asynchronous I/O for C++.


Typedef Documentation

typedef unsigned int ioxx::seconds_t

An (unsigned) quantity of seconds.

This type is useful for specifying time durations, i.e. timeouts that will occur at some point in the future.

The current time of day in microseconds since 1970-01-01 00:00:00 UTC.

POSIX.1-2001 defines this type to contain (at least) the following members:

   struct timeval
   {
     time_t      tv_sec;     // seconds
     suseconds_t tv_usec;    // microseconds
   };

The type suseconds_t is usually signed for history reasons (it used to be a long).


Function Documentation

template<class Result , class Predicate , class Action >
Result ioxx::throw_errno_if ( Predicate  is_failure,
std::string const &  error_msg,
Action  f 
)

Safety-wrapper for calling POSIX system functions.

Pretty much all system functions may fail with the EINTR condition, meaning that the call was interrupted by a signal. The throw_errno_if() combinator handles this problem transparently and restarts the function if that condition arises. All other errors will be signaled by means of a system_error exception.

Parameters:
is_failure Predicate of type bool (Result) that returns true if the returned value constitutes an error.
error_msg Context string to be used when constructing a system_error in case of an error.
f Functor of type Result () that performs the desired system call.
Returns:
The return value returned by f.
Exceptions:
system_error Thrown if the is_failure predicate returns true.
See also:
signal_block
template<class Num , class Action >
Num ioxx::throw_errno_if_minus1 ( std::string const &  error_msg,
Action const &  f 
)

Specialized version of throw_errno_if() for system calls that return -1 on error.

This combinator removes the need to specify an is_failure predicate.

Parameters:
error_msg Context string to be used when constructing a system_error in case of an error.
f Functor of type Num () that performs the desired system call.
Returns:
The return value returned by f.
Exceptions:
system_error Thrown if the is_failure predicate returns true.
Generated on Mon Mar 1 18:42:38 2010 for ioxx by  doxygen 1.6.3