00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BOOSTER_AIO_REACTOR_H
00009 #define BOOSTER_AIO_REACTOR_H
00010 #include <booster/config.h>
00011 #include <booster/aio/types.h>
00012 #include <memory>
00013 #include <string>
00014 namespace booster {
00015 namespace aio {
00016
00017 class reactor_impl;
00018
00028 class BOOSTER_API reactor : public io_events {
00029 reactor(reactor const &);
00030 void operator=(reactor const &);
00031 public:
00032
00033 static const int use_default = 0;
00034 static const int use_select = 1;
00035 static const int use_poll = 2;
00036 static const int use_epoll = 3;
00037 static const int use_dev_poll = 4;
00038 static const int use_kqueue = 5;
00039 static const int use_max = use_kqueue;
00040
00042 struct event {
00043 native_type fd;
00044 int events;
00045 };
00046
00047
00052 reactor(int hint = use_default);
00053 ~reactor();
00054
00063 void select(native_type fd,int flags);
00072 void select(native_type fd,int flags,system::error_code &e);
00078 void remove(native_type fd)
00079 {
00080 select(fd,0);
00081 }
00087 void remove(native_type fd,system::error_code &e)
00088 {
00089 select(fd,0,e);
00090 }
00091
00100 int poll(event *events,int n,int timeout);
00109 int poll(event *events,int n,int timeout,system::error_code &e);
00110
00114 std::string name() const;
00115 private:
00116 std::auto_ptr<reactor_impl> impl_;
00117 };
00118 }
00119 }
00120
00121
00122 #endif