You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2017/07/21 17:02:02 UTC
[06/20] qpid-proton git commit: PROTON-1400: [C++ binding] Remove
reactor container implementation files.
PROTON-1400: [C++ binding] Remove reactor container implementation files.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9c1797cb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9c1797cb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9c1797cb
Branch: refs/heads/master
Commit: 9c1797cbc8451ed65c2e153e0d247783200209ae
Parents: 9fad779
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Feb 8 20:12:36 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Jul 21 12:50:06 2017 -0400
----------------------------------------------------------------------
.../bindings/cpp/src/connection_options.cpp | 1 -
proton-c/bindings/cpp/src/connector.cpp | 105 ------
proton-c/bindings/cpp/src/container_impl.cpp | 365 -------------------
proton-c/bindings/cpp/src/include/acceptor.hpp | 62 ----
proton-c/bindings/cpp/src/include/connector.hpp | 66 ----
.../bindings/cpp/src/include/container_impl.hpp | 119 ------
.../cpp/src/include/event_loop_impl.hpp | 39 --
.../bindings/cpp/src/include/proton_bits.hpp | 4 -
proton-c/bindings/cpp/src/include/reactor.hpp | 100 -----
proton-c/bindings/cpp/src/reactor.cpp | 95 -----
10 files changed, 956 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp
index 4644094..6321df5 100644
--- a/proton-c/bindings/cpp/src/connection_options.cpp
+++ b/proton-c/bindings/cpp/src/connection_options.cpp
@@ -26,7 +26,6 @@
#include "proton/ssl.hpp"
#include "proton/sasl.hpp"
-#include "acceptor.hpp"
#include "contexts.hpp"
#include "messaging_adapter.hpp"
#include "msg.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.cpp b/proton-c/bindings/cpp/src/connector.cpp
deleted file mode 100644
index 0467d60..0000000
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "connector.hpp"
-
-#include "proton/connection.hpp"
-#include "proton/transport.hpp"
-#include "proton/container.hpp"
-#include "proton/reconnect_timer.hpp"
-#include "proton/sasl.hpp"
-#include "proton/url.hpp"
-
-#include "container_impl.hpp"
-#include "proton_bits.hpp"
-#include "proton_event.hpp"
-
-#include <proton/connection.h>
-#include <proton/transport.h>
-
-namespace proton {
-
-container::impl::connector::connector(connection&c, const connection_options& options, const url& a) :
- connection_(c), options_(options), address_(a), reconnect_timer_(0)
-{}
-
-container::impl::connector::~connector() { delete reconnect_timer_; }
-
-void container::impl::connector::reconnect_timer(const class reconnect_timer &rt) {
- delete reconnect_timer_;
- reconnect_timer_ = new class reconnect_timer(rt);
-}
-
-void container::impl::connector::connect() {
- pn_transport_t *pnt = pn_transport();
- transport t(make_wrapper(pnt));
- pn_transport_bind(pnt, unwrap(connection_));
- pn_decref(pnt);
- // Apply options to the new transport.
- options_.apply_bound(connection_);
-}
-
-void container::impl::connector::on_connection_local_open(proton_event &) {
- connect();
-}
-
-void container::impl::connector::on_connection_remote_open(proton_event &) {
- if (reconnect_timer_) {
- reconnect_timer_->reset();
- }
-}
-
-void container::impl::connector::on_connection_init(proton_event &) {
-}
-
-void container::impl::connector::on_transport_tail_closed(proton_event &e) {
- on_transport_closed(e);
-}
-
-void container::impl::connector::on_transport_closed(proton_event &) {
- if (!connection_) return;
- if (connection_.active()) {
- if (reconnect_timer_) {
- pn_transport_unbind(unwrap(connection_.transport()));
- int delay = reconnect_timer_->next_delay(timestamp::now());
- if (delay >= 0) {
- if (delay == 0) {
- // log "Disconnected, reconnecting..."
- connect();
- return;
- }
- else {
- // log "Disconnected, reconnecting in " << delay << " milliseconds"
- container::impl::schedule(connection_.container(), delay, this);
- return;
- }
- }
- }
- }
- pn_connection_release(unwrap(connection_));
- connection_ = 0;
-}
-
-void container::impl::connector::on_timer_task(proton_event &) {
- connect();
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
deleted file mode 100644
index e0851a9..0000000
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/connection_options.hpp"
-#include "proton/connection.hpp"
-#include "proton/error.hpp"
-#include "proton/event_loop.hpp"
-#include "proton/listener.hpp"
-#include "proton/receiver.hpp"
-#include "proton/sender.hpp"
-#include "proton/session.hpp"
-#include "proton/ssl.hpp"
-#include "proton/sasl.hpp"
-#include "proton/thread_safe.hpp"
-#include "proton/transport.hpp"
-#include "proton/url.hpp"
-#include "proton/uuid.hpp"
-
-#include "acceptor.hpp"
-#include "connector.hpp"
-#include "container_impl.hpp"
-#include "contexts.hpp"
-#include "event_loop_impl.hpp"
-#include "messaging_adapter.hpp"
-#include "msg.hpp"
-#include "proton_bits.hpp"
-#include "proton_event.hpp"
-
-#include <proton/connection.h>
-#include <proton/handlers.h>
-#include <proton/reactor.h>
-#include <proton/session.h>
-
-namespace proton {
-
-class container::impl::handler_context {
- public:
- static handler_context& get(pn_handler_t* h) {
- return *reinterpret_cast<handler_context*>(pn_handler_mem(h));
- }
- static void cleanup(pn_handler_t*) {}
-
- /*
- * NOTE: this call, at the transition from C to C++ is possibly
- * the biggest performance bottleneck. "Average" clients ignore
- * 90% of these events. Current strategy is to create the
- * messaging_event on the stack. For success, the messaging_event
- * should be small and free of indirect malloc/free/new/delete.
- */
-
- static void dispatch(pn_handler_t *c_handler, pn_event_t *c_event, pn_event_type_t)
- {
- handler_context& hc(handler_context::get(c_handler));
- proton_event pevent(c_event, hc.container_);
- pevent.dispatch(*hc.handler_);
- return;
- }
-
- container *container_;
- proton_handler *handler_;
-};
-
-// Used to sniff for connector events before the reactor's global handler sees them.
-class container::impl::override_handler : public proton_handler
-{
- public:
- internal::pn_ptr<pn_handler_t> base_handler;
- container::impl &container_impl_;
-
- override_handler(pn_handler_t *h, container::impl &c) : base_handler(h), container_impl_(c) {}
-
- virtual void on_unhandled(proton_event &pe) {
- proton_event::event_type type = pe.type();
- if (type==proton_event::EVENT_NONE) return; // Also not from the reactor
-
- pn_event_t *cevent = pe.pn_event();
- pn_connection_t *conn = pn_event_connection(cevent);
- if (conn) {
- proton_handler *oh = connection_context::get(conn).handler.get();
- if (oh && type != proton_event::CONNECTION_INIT) {
- // Send event to connector
- pe.dispatch(*oh);
- }
- else if (!oh && type == proton_event::CONNECTION_INIT) {
- // Newly accepted connection from lister socket
- connection c(make_wrapper(conn));
- container_impl_.configure_server_connection(c);
- }
- }
- pn_handler_dispatch(base_handler.get(), cevent, pn_event_type_t(type));
- }
-};
-
-internal::pn_ptr<pn_handler_t> container::impl::cpp_handler(proton_handler *h) {
- pn_handler_t *handler = h ? pn_handler_new(&handler_context::dispatch,
- sizeof(class handler_context),
- &handler_context::cleanup) : 0;
- if (handler) {
- handler_context &hc = handler_context::get(handler);
- hc.container_ = &container_;
- hc.handler_ = h;
- }
- return internal::take_ownership(handler);
-}
-
-container::impl::impl(container& c, const std::string& id, messaging_handler *mh) :
- container_(c),
- reactor_(reactor::create()),
- id_(id.empty() ? uuid::random().str() : id),
- auto_stop_(true)
-{
- container_context::set(reactor_, container_);
-
- // Set our own global handler that "subclasses" the existing one
- pn_handler_t *global_handler = reactor_.pn_global_handler();
- proton_handler* oh = new override_handler(global_handler, *this);
- handlers_.push_back(oh);
- reactor_.pn_global_handler(cpp_handler(oh).get());
- if (mh) {
- proton_handler* h = new messaging_adapter(*mh);
- handlers_.push_back(h);
- reactor_.pn_handler(cpp_handler(h).get());
- }
-
- // Note: we have just set up the following handlers that see
- // events in this order: messaging_adapter, connector override,
- // the reactor's default globalhandler (pn_iohandler)
-}
-
-namespace {
-void close_acceptor(acceptor a) {
- listen_handler*& lh = listener_context::get(unwrap(a)).listen_handler_;
- if (lh) {
- lh->on_close();
- lh = 0;
- }
- a.close();
-}
-}
-
-container::impl::~impl() {
- for (acceptors::iterator i = acceptors_.begin(); i != acceptors_.end(); ++i)
- close_acceptor(i->second);
-}
-
-// TODO aconway 2016-06-07: this is not thread safe. It is sufficient for using
-// default_container::schedule() inside a handler but not for inject() from
-// another thread.
-bool event_loop::impl::inject(void_function0& f) {
- try { f(); } catch(...) {}
- return true;
-}
-
-#if PN_CPP_HAS_STD_FUNCTION
-bool event_loop::impl::inject(std::function<void()> f) {
- try { f(); } catch(...) {}
- return true;
-}
-#endif
-
-returned<connection> container::impl::connect(const std::string &urlstr, const connection_options &user_opts) {
- connection_options opts = client_connection_options(); // Defaults
- opts.update(user_opts);
- messaging_handler* mh = opts.handler();
- internal::pn_ptr<pn_handler_t> chandler;
- if (mh) {
- proton_handler* h = new messaging_adapter(*mh);
- handlers_.push_back(h);
- chandler = cpp_handler(h);
- }
-
- proton::url url(urlstr);
- connection conn(reactor_.connection_to_host(url.host(), url.port(), chandler.get()));
- internal::pn_unique_ptr<connector> ctor(new connector(conn, opts, url));
- connection_context& cc(connection_context::get(unwrap(conn)));
- cc.handler.reset(ctor.release());
- cc.event_loop_ = new event_loop::impl;
-
- pn_connection_t *pnc = unwrap(conn);
- pn_connection_set_container(pnc, id_.c_str());
- pn_connection_set_hostname(pnc, url.host().c_str());
- if (!url.user().empty())
- pn_connection_set_user(pnc, url.user().c_str());
- if (!url.password().empty())
- pn_connection_set_password(pnc, url.password().c_str());
-
- conn.open(opts);
- return make_thread_safe(conn);
-}
-
-returned<sender> container::impl::open_sender(const std::string &url, const proton::sender_options &o1, const connection_options &o2) {
- proton::sender_options lopts(sender_options_);
- lopts.update(o1);
- connection_options copts(client_connection_options_);
- copts.update(o2);
- connection conn = connect(url, copts);
- return make_thread_safe(conn.default_session().open_sender(proton::url(url).path(), lopts));
-}
-
-returned<receiver> container::impl::open_receiver(const std::string &url, const proton::receiver_options &o1, const connection_options &o2) {
- proton::receiver_options lopts(receiver_options_);
- lopts.update(o1);
- connection_options copts(client_connection_options_);
- copts.update(o2);
- connection conn = connect(url, copts);
- return make_thread_safe(
- conn.default_session().open_receiver(proton::url(url).path(), lopts));
-}
-
-listener container::impl::listen(const std::string& url, listen_handler& lh) {
- if (acceptors_.find(url) != acceptors_.end())
- throw error("already listening on " + url);
- connection_options opts = server_connection_options(); // Defaults
-
- messaging_handler* mh = opts.handler();
- internal::pn_ptr<pn_handler_t> chandler;
- if (mh) {
- proton_handler* h = new messaging_adapter(*mh);
- handlers_.push_back(h);
- chandler = cpp_handler(h);
- }
-
- proton::url u(url);
- pn_acceptor_t *acptr = pn_reactor_acceptor(
- unwrap(reactor_), u.host().c_str(), u.port().c_str(), chandler.get());
- if (!acptr) {
- std::string err(pn_error_text(pn_reactor_error(unwrap(reactor_))));
- lh.on_error(err);
- lh.on_close();
- throw error(err);
- }
- // Do not use pn_acceptor_set_ssl_domain(). Manage the incoming connections ourselves for
- // more flexibility (i.e. ability to change the server cert for a long running listener).
- listener_context& lc(listener_context::get(acptr));
- lc.listen_handler_ = &lh;
- lc.ssl = u.scheme() == url::AMQPS;
- listener_context::get(acptr).listen_handler_ = &lh;
- acceptors_[url] = make_wrapper(acptr);
- return listener(container_, url);
-}
-
-void container::impl::stop_listening(const std::string& url) {
- acceptors::iterator i = acceptors_.find(url);
- if (i != acceptors_.end())
- close_acceptor(i->second);
-}
-
-void container::impl::schedule(impl& ci, int delay, proton_handler *h) {
- internal::pn_ptr<pn_handler_t> task_handler;
- if (h)
- task_handler = ci.cpp_handler(h);
- ci.reactor_.schedule(delay, task_handler.get());
-}
-
-void container::impl::schedule(container& c, int delay, proton_handler *h) {
- schedule(*c.impl_.get(), delay, h);
-}
-
-namespace {
-// Abstract base for timer_handler_std and timer_handler_03
-struct timer_handler : public proton_handler, public void_function0 {
- void on_timer_task(proton_event& ) PN_CPP_OVERRIDE {
- (*this)();
- delete this;
- }
- void on_reactor_final(proton_event&) PN_CPP_OVERRIDE {
- delete this;
- }
-};
-
-struct timer_handler_03 : public timer_handler {
- void_function0& func;
- timer_handler_03(void_function0& f): func(f) {}
- void operator()() PN_CPP_OVERRIDE { func(); }
-};
-}
-
-void container::impl::schedule(duration delay, void_function0& f) {
- schedule(*this, delay.milliseconds(), new timer_handler_03(f));
-}
-
-#if PN_CPP_HAS_STD_FUNCTION
-namespace {
-struct timer_handler_std : public timer_handler {
- std::function<void()> func;
- timer_handler_std(std::function<void()> f): func(f) {}
- void operator()() PN_CPP_OVERRIDE { func(); }
-};
-}
-
-void container::impl::schedule(duration delay, std::function<void()> f) {
- schedule(*this, delay.milliseconds(), new timer_handler_std(f));
-}
-#endif
-
-void container::impl::client_connection_options(const connection_options &opts) {
- client_connection_options_ = opts;
-}
-
-void container::impl::server_connection_options(const connection_options &opts) {
- server_connection_options_ = opts;
-}
-
-void container::impl::sender_options(const proton::sender_options &opts) {
- sender_options_ = opts;
-}
-
-void container::impl::receiver_options(const proton::receiver_options &opts) {
- receiver_options_ = opts;
-}
-
-void container::impl::configure_server_connection(connection &c) {
- pn_acceptor_t *pnp = pn_connection_acceptor(unwrap(c));
- listener_context &lc(listener_context::get(pnp));
- pn_connection_set_container(unwrap(c), id_.c_str());
- connection_options opts = server_connection_options_;
- opts.update(lc.get_options());
- // Unbound options don't apply to server connection
- opts.apply_bound(c);
- // Handler applied separately
- messaging_handler* mh = opts.handler();
- if (mh) {
- proton_handler* h = new messaging_adapter(*mh);
- handlers_.push_back(h);
- internal::pn_ptr<pn_handler_t> chandler = cpp_handler(h);
- pn_record_t *record = pn_connection_attachments(unwrap(c));
- pn_record_set_handler(record, chandler.get());
- }
- connection_context::get(unwrap(c)).event_loop_ = new event_loop::impl;
-}
-
-void container::impl::run() {
- do {
- reactor_.run();
- } while (!auto_stop_);
-}
-
-void container::impl::stop(const error_condition&) {
- reactor_.stop();
- auto_stop_ = true;
-}
-
-void container::impl::auto_stop(bool set) {
- auto_stop_ = set;
-}
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/acceptor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/acceptor.hpp b/proton-c/bindings/cpp/src/include/acceptor.hpp
deleted file mode 100644
index 9a25592..0000000
--- a/proton-c/bindings/cpp/src/include/acceptor.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef PROTON_ACCEPTOR_HPP
-#define PROTON_ACCEPTOR_HPP
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/internal/export.hpp"
-#include "proton/internal/object.hpp"
-
-#include <proton/reactor.h>
-
-struct pn_acceptor_t;
-
-namespace proton {
-
-/// A context for accepting inbound connections.
-///
-/// @see container::listen
-class acceptor : public internal::object<pn_acceptor_t> {
- /// @cond INTERNAL
- acceptor(pn_acceptor_t* a) : internal::object<pn_acceptor_t>(a) {}
- /// @endcond
-
- public:
- acceptor() : internal::object<pn_acceptor_t>(0) {}
-
- /// Close the acceptor.
- PN_CPP_EXTERN void close();
-
- /// Return the current set of connection options applied to
- /// inbound connectons by the acceptor.
- ///
- /// Note that changes made to the connection options only affect
- /// connections accepted after this call returns.
- PN_CPP_EXTERN class connection_options &connection_options();
-
- /// @cond INTERNAL
- friend class internal::factory<acceptor>;
- /// @endcond
-};
-
-} // proton
-
-#endif // PROTON_ACCEPTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/connector.hpp b/proton-c/bindings/cpp/src/include/connector.hpp
deleted file mode 100644
index 6bcd0db..0000000
--- a/proton-c/bindings/cpp/src/include/connector.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef PROTON_CPP_CONNECTOR_HANDLER_H
-#define PROTON_CPP_CONNECTOR_HANDLER_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/connection.hpp"
-#include "proton/connection_options.hpp"
-#include <proton/event.h>
-#include <proton/reactor.h>
-#include "proton/url.hpp"
-
-#include "container_impl.hpp"
-#include "proton_handler.hpp"
-
-#include <string>
-
-
-namespace proton {
-
-class reconnect_timer;
-
-class container::impl::connector : public proton_handler
-{
- public:
- connector(connection &c, const connection_options &options, const url&);
- ~connector();
- const url &address() const { return address_; }
- void connect();
- void reconnect_timer(const class reconnect_timer &);
- virtual void on_connection_local_open(proton_event &e);
- virtual void on_connection_remote_open(proton_event &e);
- virtual void on_connection_init(proton_event &e);
- virtual void on_transport_closed(proton_event &e);
- virtual void on_transport_tail_closed(proton_event &e);
- virtual void on_timer_task(proton_event &e);
-
- private:
- connection connection_;
- const connection_options options_;
- const url address_;
- class reconnect_timer *reconnect_timer_;
-};
-
-
-}
-
-#endif /*!PROTON_CPP_CONNECTOR_HANDLER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/container_impl.hpp b/proton-c/bindings/cpp/src/include/container_impl.hpp
deleted file mode 100644
index 7443150..0000000
--- a/proton-c/bindings/cpp/src/include/container_impl.hpp
+++ /dev/null
@@ -1,119 +0,0 @@
-#ifndef PROTON_CPP_CONTAINERIMPL_H
-#define PROTON_CPP_CONTAINERIMPL_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/fwd.hpp"
-#include "proton/container.hpp"
-#include "proton/connection.hpp"
-#include "proton/connection_options.hpp"
-#include "proton/duration.hpp"
-#include "proton/sender.hpp"
-#include "proton/sender_options.hpp"
-#include "proton/receiver.hpp"
-#include "proton/receiver_options.hpp"
-
-#include "messaging_adapter.hpp"
-#include "reactor.hpp"
-#include "proton_bits.hpp"
-#include "proton_handler.hpp"
-
-#include <list>
-#include <map>
-#include <string>
-
-namespace proton {
-
-class dispatch_helper;
-class connector;
-class acceptor;
-class url;
-class listen_handler;
-
-class container::impl {
- public:
- impl(container& c, const std::string& id, messaging_handler* = 0);
- ~impl();
- std::string id() const { return id_; }
- returned<connection> connect(const std::string&, const connection_options&);
- returned<sender> open_sender(
- const std::string&, const proton::sender_options &, const connection_options &);
- returned<receiver> open_receiver(
- const std::string&, const proton::receiver_options &, const connection_options &);
- listener listen(const std::string&, listen_handler& lh);
- void stop_listening(const std::string&);
- void client_connection_options(const connection_options &);
- connection_options client_connection_options() const { return client_connection_options_; }
- void server_connection_options(const connection_options &);
- connection_options server_connection_options() const { return server_connection_options_; }
- void sender_options(const proton::sender_options&);
- class sender_options sender_options() const { return sender_options_; }
- void receiver_options(const proton::receiver_options&);
- class receiver_options receiver_options() const { return receiver_options_; }
- void run();
- void stop(const error_condition& err);
- void auto_stop(bool set);
- void schedule(duration, void_function0&);
-#if PN_CPP_HAS_STD_FUNCTION
- void schedule(duration, std::function<void()>);
-#endif
-
- // non-interface functionality
- class connector;
-
- void configure_server_connection(connection &c);
- static void schedule(impl& ci, int delay, proton_handler *h);
- static void schedule(container& c, int delay, proton_handler *h);
- template <class T> static void set_handler(T s, messaging_handler* h);
-
- private:
- class handler_context;
- class override_handler;
-
- internal::pn_ptr<pn_handler_t> cpp_handler(proton_handler *h);
-
- container& container_;
- reactor reactor_;
- // Keep a list of all the handlers used by the container so they last as long as the container
- std::list<internal::pn_unique_ptr<proton_handler> > handlers_;
- std::string id_;
- connection_options client_connection_options_;
- connection_options server_connection_options_;
- proton::sender_options sender_options_;
- proton::receiver_options receiver_options_;
- typedef std::map<std::string, acceptor> acceptors;
- acceptors acceptors_;
- bool auto_stop_;
-};
-
-template <class T>
-void container::impl::set_handler(T s, messaging_handler* mh) {
- pn_record_t *record = internal::get_attachments(unwrap(s));
- proton_handler* h = new messaging_adapter(*mh);
- impl* ci = s.container().impl_.get();
- ci->handlers_.push_back(h);
- pn_record_set_handler(record, ci->cpp_handler(h).get());
-}
-
-}
-
-#endif /*!PROTON_CPP_CONTAINERIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/event_loop_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/event_loop_impl.hpp b/proton-c/bindings/cpp/src/include/event_loop_impl.hpp
deleted file mode 100644
index b34a981..0000000
--- a/proton-c/bindings/cpp/src/include/event_loop_impl.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef PROTON_CPP_EVENT_LOOP_IMPL_HPP
-#define PROTON_CPP_EVENT_LOOP_IMPL_HPP
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "proton/fwd.hpp"
-
-namespace proton {
-
-class event_loop::impl {
- public:
- bool inject(void_function0& f);
-#if PN_CPP_HAS_CPP11
- bool inject(std::function<void()> f);
-#endif
-};
-
-}
-
-#endif // PROTON_CPP_EVENT_LOOP_IMPL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proton_bits.hpp b/proton-c/bindings/cpp/src/include/proton_bits.hpp
index e72f343..fdd79b5 100644
--- a/proton-c/bindings/cpp/src/include/proton_bits.hpp
+++ b/proton-c/bindings/cpp/src/include/proton_bits.hpp
@@ -102,11 +102,9 @@ template <> struct wrapped<transfer> { typedef pn_delivery_t type; };
template <> struct wrapped<tracker> { typedef pn_delivery_t type; };
template <> struct wrapped<delivery> { typedef pn_delivery_t type; };
template <> struct wrapped<error_condition> { typedef pn_condition_t type; };
-template <> struct wrapped<acceptor> { typedef pn_acceptor_t type; }; // TODO aconway 2016-05-13: reactor only
template <> struct wrapped<terminus> { typedef pn_terminus_t type; };
template <> struct wrapped<source> { typedef pn_terminus_t type; };
template <> struct wrapped<target> { typedef pn_terminus_t type; };
-template <> struct wrapped<reactor> { typedef pn_reactor_t type; };
template <class T> struct wrapper {};
template <> struct wrapper<pn_data_t> { typedef internal::data type; };
@@ -118,9 +116,7 @@ template <> struct wrapper<pn_session_t> { typedef session type; };
template <> struct wrapper<pn_link_t> { typedef link type; };
template <> struct wrapper<pn_delivery_t> { typedef transfer type; };
template <> struct wrapper<pn_condition_t> { typedef error_condition type; };
-template <> struct wrapper<pn_acceptor_t> { typedef acceptor type; };
template <> struct wrapper<pn_terminus_t> { typedef terminus type; };
-template <> struct wrapper<pn_reactor_t> { typedef reactor type; };
// Factory for wrapper types
template <class T>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/include/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/reactor.hpp b/proton-c/bindings/cpp/src/include/reactor.hpp
deleted file mode 100644
index 07678e4..0000000
--- a/proton-c/bindings/cpp/src/include/reactor.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef REACTOR_HPP
-#define REACTOR_HPP
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/// @cond INTERNAL
-/// XXX remove
-
-#include "proton/fwd.hpp"
-#include "proton/internal/object.hpp"
-#include "proton/duration.hpp"
-#include "proton/timestamp.hpp"
-
-struct pn_reactor_t;
-struct pn_handler_t;
-struct pn_io_t;
-
-namespace proton {
-
-class acceptor;
-
-class reactor : public internal::object<pn_reactor_t> {
- public:
- reactor(pn_reactor_t* r = 0) : internal::object<pn_reactor_t>(r) {}
-
- /** Create a new reactor. */
- static reactor create();
-
- /** Open a connection to url and create a receiver with source=url.path() */
- acceptor listen(const proton::url &);
-
- /** Run the event loop, return when all connections and acceptors are closed. */
- void run();
-
- /** Start the reactor, you must call process() to process events */
- void start();
-
- /** Process events, return true if there are more events to process. */
- bool process();
-
- /** Stop the reactor, causes run() to return and process() to return false. */
- void stop();
-
- /// Identifier for the container
- std::string id() const;
-
- /// Get timeout, process() will return if there is no activity within the timeout.
- duration timeout();
-
- /// Set timeout, process() will return if there is no activity within the timeout.
- void timeout(duration timeout);
-
- timestamp mark();
- timestamp now();
-
- void schedule(int, pn_handler_t*);
-
- class connection connection(pn_handler_t*) const;
-
- class connection connection_to_host(const std::string &host, const std::string &port, pn_handler_t*) const;
-
- pn_handler_t* pn_handler() const;
-
- void pn_handler(pn_handler_t* );
-
- pn_handler_t* pn_global_handler() const;
-
- void pn_global_handler(pn_handler_t* );
-
- pn_io_t* pn_io() const;
-
- void wakeup();
- bool quiesced();
- void yield();
-
- friend class internal::factory<reactor>;
-};
-
-}
-
-/// @endcond
-
-#endif // REACTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9c1797cb/proton-c/bindings/cpp/src/reactor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.cpp b/proton-c/bindings/cpp/src/reactor.cpp
deleted file mode 100644
index 39f670f..0000000
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "reactor.hpp"
-#include "acceptor.hpp"
-
-#include "proton/connection.hpp"
-#include "proton/url.hpp"
-
-#include "contexts.hpp"
-#include "proton_bits.hpp"
-
-#include <proton/reactor.h>
-
-namespace proton {
-
-reactor reactor::create() {
- return internal::take_ownership(pn_reactor()).get();
-}
-
-void reactor::run() { pn_reactor_run(pn_object()); }
-void reactor::start() { pn_reactor_start(pn_object()); }
-bool reactor::process() { return pn_reactor_process(pn_object()); }
-void reactor::stop() { pn_reactor_stop(pn_object()); }
-void reactor::wakeup() { pn_reactor_wakeup(pn_object()); }
-bool reactor::quiesced() { return pn_reactor_quiesced(pn_object()); }
-void reactor::yield() { pn_reactor_yield(pn_object()); }
-timestamp reactor::mark() { return timestamp(pn_reactor_mark(pn_object())); }
-timestamp reactor::now() { return timestamp(pn_reactor_now(pn_object())); }
-
-void acceptor::close() { pn_acceptor_close(pn_object()); }
-
-acceptor reactor::listen(const url& url){
- return make_wrapper(pn_reactor_acceptor(pn_object(), url.host().c_str(), url.port().c_str(), 0));
-}
-
-void reactor::schedule(int delay, pn_handler_t* handler) {
- pn_reactor_schedule(pn_object(), delay, handler);
-}
-
-connection reactor::connection(pn_handler_t* h) const {
- return make_wrapper(pn_reactor_connection(pn_object(), h));
-}
-
-connection reactor::connection_to_host(const std::string &host, const std::string &port, pn_handler_t* h) const {
- return make_wrapper(pn_reactor_connection_to_host(pn_object(), host.c_str(), port.c_str(), h));
-}
-
-void reactor::pn_handler(pn_handler_t* h) {
- pn_reactor_set_handler(pn_object(), h);
-}
-
-pn_handler_t* reactor::pn_handler() const {
- return pn_reactor_get_handler(pn_object());
-}
-
-void reactor::pn_global_handler(pn_handler_t* h) {
- pn_reactor_set_global_handler(pn_object(), h);
-}
-
-pn_handler_t* reactor::pn_global_handler() const {
- return pn_reactor_get_global_handler(pn_object());
-}
-
-duration reactor::timeout() {
- pn_millis_t tmo = pn_reactor_get_timeout(pn_object());
- if (tmo == PN_MILLIS_MAX)
- return duration::FOREVER;
- return duration(tmo);
-}
-
-void reactor::timeout(duration timeout) {
- if (timeout == duration::FOREVER || timeout.milliseconds() > PN_MILLIS_MAX)
- pn_reactor_set_timeout(pn_object(), PN_MILLIS_MAX);
- else
- pn_reactor_set_timeout(pn_object(), timeout.milliseconds());
-}
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org