CppCMS
io_service.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_IO_SERVICE_H
9 #define BOOSTER_AIO_IO_SERVICE_H
10 
11 #include <booster/config.h>
12 #include <booster/aio/aio_config.h>
13 #include <booster/aio/types.h>
14 #include <booster/thread.h>
15 #include <booster/system_error.h>
16 #include <booster/aio/aio_category.h>
17 #include <booster/callback.h>
18 #include <booster/noncopyable.h>
19 #include <string>
20 #include <booster/auto_ptr_inc.h>
21 
22 namespace booster {
23 class ptime;
24 namespace aio {
25 
26  class event_loop_impl;
27 
28 
37  class BOOSTER_API io_service : public noncopyable, public io_events {
38  public:
39 
43  io_service(int reactor_type);
47  io_service();
51  ~io_service();
52 
62  void set_io_event(native_type fd,int event,event_handler const &h);
67  void cancel_io_events(native_type fd);
68 
80  int set_timer_event(ptime const &point,event_handler const &h);
81 
85  void cancel_timer_event(int event_id);
86 
96  void run();
97 
102  void run(system::error_code &e);
103 
107  void reset();
112  void stop();
113 
118  void post(handler const &h);
119 
124  void post(event_handler const &h,booster::system::error_code const &e);
129  void post(io_handler const &h,booster::system::error_code const &e,size_t n);
130 
131 
135 
136  std::string reactor_name();
137  private:
138  struct data;
139  hold_ptr<data> d;
140  std::auto_ptr<event_loop_impl> impl_;
141  };
142 
143 } // aio
144 } // booster
145 
146 #endif
the struct that collects multiple event types for polling.
Definition: types.h:86
Definition: callback.h:18
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
This class represents POSIX time.
Definition: posix_time.h:26
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
Stop conversion and throw conversion_error.
Definition: encoding_errors.h:56
this is the central event loop that dispatches all requests.
Definition: io_service.h:37
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15