reactor.h
//
// Copyright (C) 2009-2012 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOSTER_AIO_REACTOR_H
#define BOOSTER_AIO_REACTOR_H
#include <booster/config.h>
#include <booster/aio/types.h>
#include <memory>
#include <string>
namespace booster {
namespace aio {
class reactor_impl;
class BOOSTER_API reactor : public io_events {
reactor(reactor const &);
void operator=(reactor const &);
public:
static const int use_default = 0; //< Best polling device available on the OS
static const int use_select = 1; //< select() API, default on Windows
static const int use_poll = 2; //< poll() API default on POSIX platforms without better polling support
static const int use_epoll = 3; //< epoll() available and default on Linux
static const int use_dev_poll = 4; //< /dev/poll available and default on Solaris and HP-UX
static const int use_kqueue = 5; //< kqueue available and default on BSD and Mac OS X.
static const int use_max = use_kqueue; //< Maximal number
struct event {
native_type fd; //< A descriptor that event occurred on
int events; //< a bit mask of events \see io_events
};
reactor(int hint = use_default);
~reactor();
void select(native_type fd,int flags);
void select(native_type fd,int flags,system::error_code &e);
void remove(native_type fd)
{
select(fd,0);
}
void remove(native_type fd,system::error_code &e)
{
select(fd,0,e);
}
int poll(event *events,int n,int timeout);
int poll(event *events,int n,int timeout,system::error_code &e);
std::string name() const;
private:
std::auto_ptr<reactor_impl> impl_;
};
} // aio
} // booster
#endif
booster::aio::reactor
This class is an abstraction of platform dependent polling API.
Definition: reactor.h:28
booster::aio::io_events
the struct that collects multiple event types for polling.
Definition: types.h:86
booster::aio::reactor::event
structure that defines output events
Definition: reactor.h:42
booster::system::error_code
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
booster::aio::native_type
unspecified native_type
Definition: types.h:29