CppCMS
reactor.h
1 //
2 // Copyright (C) 2009-2012 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOSTER_AIO_REACTOR_H
9 #define BOOSTER_AIO_REACTOR_H
10 #include <booster/config.h>
11 #include <booster/aio/types.h>
12 #include <booster/auto_ptr_inc.h>
13 #include <string>
14 namespace booster {
15 namespace aio {
16 
17  class reactor_impl;
18 
28  class BOOSTER_API reactor : public io_events {
29  reactor(reactor const &);
30  void operator=(reactor const &);
31  public:
32 
33  static const int use_default = 0; //< Best polling device available on the OS
34  static const int use_select = 1; //< select() API, default on Windows
35  static const int use_poll = 2; //< poll() API default on POSIX platforms without better polling support
36  static const int use_epoll = 3; //< epoll() available and default on Linux
37  static const int use_dev_poll = 4; //< /dev/poll available and default on Solaris and HP-UX
38  static const int use_kqueue = 5; //< kqueue available and default on BSD and Mac OS X.
39  static const int use_max = use_kqueue; //< Maximal number
40 
42  struct event {
43  native_type fd; //< A descriptor that event occurred on
44  int events; //< a bit mask of events \see io_events
45  };
46 
47 
52  reactor(int hint = use_default);
53  ~reactor();
54 
63  void select(native_type fd,int flags);
72  void select(native_type fd,int flags,system::error_code &e);
78  void remove(native_type fd)
79  {
80  select(fd,0);
81  }
87  void remove(native_type fd,system::error_code &e)
88  {
89  select(fd,0,e);
90  }
91 
100  int poll(event *events,int n,int timeout);
109  int poll(event *events,int n,int timeout,system::error_code &e);
110 
114  std::string name() const;
115  private:
116  std::auto_ptr<reactor_impl> impl_;
117  };
118 } // aio
119 } // booster
120 
121 
122 #endif
This class is an abstraction of platform dependent polling API.
Definition: reactor.h:28
the struct that collects multiple event types for polling.
Definition: types.h:86
structure that defines output events
Definition: reactor.h:42
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
unspecified native_type
Definition: types.h:29
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23