CppCMS
|
00001 // 00002 // Copyright (C) 2009-2012 Artyom Beilis (Tonkikh) 00003 // 00004 // Distributed under the Boost Software License, Version 1.0. (See 00005 // accompanying file LICENSE_1_0.txt or copy at 00006 // http://www.boost.org/LICENSE_1_0.txt) 00007 // 00008 #ifndef BOOSTER_AIO_IO_SERVICE_H 00009 #define BOOSTER_AIO_IO_SERVICE_H 00010 00011 #include <booster/config.h> 00012 #include <booster/aio/aio_config.h> 00013 #include <booster/aio/types.h> 00014 #include <booster/thread.h> 00015 #include <booster/system_error.h> 00016 #include <booster/aio/aio_category.h> 00017 #include <booster/callback.h> 00018 #include <booster/noncopyable.h> 00019 #include <string> 00020 #include <memory> 00021 00022 namespace booster { 00023 class ptime; 00024 namespace aio { 00025 00026 class event_loop_impl; 00027 00028 00037 class BOOSTER_API io_service : public noncopyable, public io_events { 00038 public: 00039 00043 io_service(int reactor_type); 00047 io_service(); 00051 ~io_service(); 00052 00062 void set_io_event(native_type fd,int event,event_handler const &h); 00067 void cancel_io_events(native_type fd); 00068 00080 int set_timer_event(ptime const &point,event_handler const &h); 00081 00085 void cancel_timer_event(int event_id); 00086 00096 void run(); 00097 00102 void run(system::error_code &e); 00103 00107 void reset(); 00112 void stop(); 00113 00118 void post(handler const &h); 00119 00123 00124 std::string reactor_name(); 00125 private: 00126 struct data; 00127 hold_ptr<data> d; 00128 std::auto_ptr<event_loop_impl> impl_; 00129 }; 00130 00131 } // aio 00132 } // booster 00133 00134 #endif