Qpid Proton C++  0.17.0
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 "./fwd.hpp"
26 #include "./internal/config.hpp"
27 #include "./internal/export.hpp"
28 #include "./internal/pn_unique_ptr.hpp"
29 
30 #include <functional>
31 
32 struct pn_connection_t;
33 struct pn_session_t;
34 struct pn_link_t;
35 
36 namespace proton {
37 
44 class PN_CPP_CLASS_EXTERN event_loop {
46  class impl;
47  event_loop& operator=(impl* i);
49 
50  public:
52  PN_CPP_EXTERN event_loop();
53 
54  PN_CPP_EXTERN ~event_loop();
55 
56 #if PN_CPP_HAS_EXPLICIT_CONVERSIONS
57  PN_CPP_EXTERN explicit operator bool() const { return bool(impl_); }
60 #endif
61 
63  PN_CPP_EXTERN bool operator !() const { return !impl_; }
64 
70  PN_CPP_EXTERN bool inject(void_function0& f);
71 
72 #if PN_CPP_HAS_STD_FUNCTION
73  PN_CPP_EXTERN bool inject(std::function<void()> f);
75 #endif
76 
77  private:
78  PN_CPP_EXTERN static event_loop& get(pn_connection_t*);
79  PN_CPP_EXTERN static event_loop& get(pn_session_t*);
80  PN_CPP_EXTERN static event_loop& get(pn_link_t*);
81 
82  internal::pn_unique_ptr<impl> impl_;
83 
85  friend class container;
86  friend class io::connection_driver;
87  template <class T> friend class thread_safe;
89 };
90 
91 } // proton
92 
93 #endif // PROTON_EVENT_LOOP_HPP
A top-level container of connections, sessions, senders, and receivers.
Definition: container.hpp:50
Experimental - A serial execution context.
Definition: event_loop.hpp:44
A C++03 compatible void no-argument callback function object.
Definition: function.hpp:35
Experimental - An AMQP driver for a single connection.
Definition: connection_driver.hpp:94
The main Proton namespace.
Definition: annotation_key.hpp:30
Experimental - A thread-safe object wrapper.
Definition: fwd.hpp:65