Qpid Proton C++  0.14.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
event_loop.hpp
1 #ifndef PROTON_EVENT_LOOP_HPP
2 #define PROTON_EVENT_LOOP_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./internal/config.hpp"
26 #include "./function.hpp"
27 
28 #include <functional>
29 
30 #if PN_CPP_HAS_CPP11
31 #include <future>
32 #include <type_traits>
33 #endif
34 
35 struct pn_connection_t;
36 struct pn_session_t;
37 struct pn_link_t;
38 
39 namespace proton {
40 
45  public:
46  virtual ~inject_handler() {}
47  virtual void on_inject() = 0;
48  void operator()() { on_inject(); }
49 };
50 
57 class PN_CPP_CLASS_EXTERN event_loop {
58  public:
59  virtual ~event_loop() {}
60 
66  virtual bool inject(void_function0& f) = 0;
67 
68 #if PN_CPP_HAS_STD_FUNCTION
69  virtual bool inject(std::function<void()> f) = 0;
71 #endif
72 
73  protected:
74  event_loop() {}
75 
76  private:
77  PN_CPP_EXTERN static event_loop* get(pn_connection_t*);
78  PN_CPP_EXTERN static event_loop* get(pn_session_t*);
79  PN_CPP_EXTERN static event_loop* get(pn_link_t*);
80 
82  friend class connection;
83  template <class T> friend class thread_safe;
85 };
86 
87 } // proton
88 
89 #endif // PROTON_EVENT_LOOP_HPP
A connection to a remote AMQP peer.
Definition: connection.hpp:48
void operator()()
Override the call operator with your code.
Definition: event_loop.hpp:48
Experimental - A serial execution context.
Definition: event_loop.hpp:57
A C++03 compatible void no-argument callback function object, used by container::schedule() and event...
Definition: function.hpp:33
Experimental - A thread-safe object wrapper.
Definition: connection.hpp:45
Experimental - A handler for injected code.
Definition: event_loop.hpp:44
Type traits for mapping between AMQP and C++ types.
Definition: annotation_key.hpp:28