00001 #ifndef PROTON_EVENT_LOOP_HPP
00002 #define PROTON_EVENT_LOOP_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "./internal/config.hpp"
00026 #include "./function.hpp"
00027
00028 #include <functional>
00029
00030 #if PN_CPP_HAS_CPP11
00031 #include <future>
00032 #include <type_traits>
00033 #endif
00034
00035 struct pn_connection_t;
00036 struct pn_session_t;
00037 struct pn_link_t;
00038
00039 namespace proton {
00040
00044 class inject_handler : public void_function0 {
00045 public:
00046 virtual ~inject_handler() {}
00047 virtual void on_inject() = 0;
00048 void operator()() { on_inject(); }
00049 };
00050
00057 class PN_CPP_CLASS_EXTERN event_loop {
00058 public:
00059 virtual ~event_loop() {}
00060
00066 virtual bool inject(void_function0& f) = 0;
00067
00068 #if PN_CPP_HAS_STD_FUNCTION
00070 virtual bool inject(std::function<void()> f) = 0;
00071 #endif
00072
00073 protected:
00074 event_loop() {}
00075
00076 private:
00077 PN_CPP_EXTERN static event_loop* get(pn_connection_t*);
00078 PN_CPP_EXTERN static event_loop* get(pn_session_t*);
00079 PN_CPP_EXTERN static event_loop* get(pn_link_t*);
00080
00082 friend class connection;
00083 template <class T> friend class thread_safe;
00085 };
00086
00087 }
00088
00089 #endif // PROTON_EVENT_LOOP_HPP