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 2016/03/02 16:42:54 UTC
[4/5] qpid-proton git commit: PROTON-1153: [C+ binding] Made reactor
an internal class - Moved header file from exported headers to internal
source - Reworked reconnect_timer to not use reactor at all
PROTON-1153: [C+ binding] Made reactor an internal class
- Moved header file from exported headers to internal source
- Reworked reconnect_timer to not use reactor at all
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d758832d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d758832d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d758832d
Branch: refs/heads/master
Commit: d758832dd7341f786617502ace6cc0f0f08cc140
Parents: 3b62bf9
Author: Andrew Stitcher <as...@apache.org>
Authored: Mon Feb 29 23:25:24 2016 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Mar 2 10:35:29 2016 -0500
----------------------------------------------------------------------
.../cpp/include/proton/connection_engine.hpp | 2 +-
.../cpp/include/proton/connection_options.hpp | 3 +-
.../bindings/cpp/include/proton/container.hpp | 3 +-
.../bindings/cpp/include/proton/handler.hpp | 2 +-
proton-c/bindings/cpp/include/proton/io.hpp | 1 +
.../cpp/include/proton/link_options.hpp | 2 +-
.../cpp/include/proton/pn_unique_ptr.hpp | 7 +-
.../bindings/cpp/include/proton/reactor.hpp | 102 -------------------
.../cpp/include/proton/reconnect_timer.hpp | 19 ++--
.../bindings/cpp/include/proton/timestamp.hpp | 1 +
proton-c/bindings/cpp/src/connector.cpp | 3 +-
proton-c/bindings/cpp/src/container_impl.cpp | 2 +-
proton-c/bindings/cpp/src/container_impl.hpp | 6 +-
proton-c/bindings/cpp/src/contexts.cpp | 1 +
proton-c/bindings/cpp/src/contexts.hpp | 3 +-
proton-c/bindings/cpp/src/messaging_adapter.hpp | 2 +-
proton-c/bindings/cpp/src/reactor.cpp | 3 +-
proton-c/bindings/cpp/src/reactor.hpp | 102 +++++++++++++++++++
proton-c/bindings/cpp/src/reconnect_timer.cpp | 24 ++---
19 files changed, 143 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/connection_engine.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
index 4834c18..be6f19c 100644
--- a/proton-c/bindings/cpp/include/proton/connection_engine.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_engine.hpp
@@ -88,7 +88,7 @@ PN_CPP_CLASS_EXTERN connection_engine {
private:
class impl;
- pn_unique_ptr<impl> impl_;
+ internal::pn_unique_ptr<impl> impl_;
};
/// Create a connection engine that dispatches to handler.
PN_CPP_EXTERN connection_engine(handler&, const connection_options& = no_opts);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp
index 818e82a..6af4784 100644
--- a/proton-c/bindings/cpp/include/proton/connection_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp
@@ -24,6 +24,7 @@
#include "proton/config.hpp"
#include "proton/export.hpp"
+#include "proton/duration.hpp"
#include "proton/pn_unique_ptr.hpp"
#include "proton/reconnect_timer.hpp"
#include "proton/types.hpp"
@@ -143,7 +144,7 @@ class connection_options {
class ssl_server_options &ssl_server_options();
class impl;
- pn_unique_ptr<impl> impl_;
+ internal::pn_unique_ptr<impl> impl_;
friend class container_impl;
friend class connector;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 6532e20..0af1963 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -25,7 +25,6 @@
#include "proton/duration.hpp"
#include "proton/export.hpp"
#include "proton/pn_unique_ptr.hpp"
-#include "proton/reactor.hpp"
#include "proton/url.hpp"
#include "proton/connection_options.hpp"
#include "proton/link_options.hpp"
@@ -131,7 +130,7 @@ class container {
/// The reactor associated with this container.
class reactor reactor() const;
- pn_unique_ptr<container_impl> impl_;
+ internal::pn_unique_ptr<container_impl> impl_;
friend class connector;
friend class link;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/handler.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp
index 28da99d..3bc0023 100644
--- a/proton-c/bindings/cpp/include/proton/handler.hpp
+++ b/proton-c/bindings/cpp/include/proton/handler.hpp
@@ -149,7 +149,7 @@ PN_CPP_CLASS_EXTERN handler
/// @cond INTERNAL
private:
- pn_unique_ptr<messaging_adapter> messaging_adapter_;
+ internal::pn_unique_ptr<messaging_adapter> messaging_adapter_;
friend class container;
friend class connection_engine;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/io.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/io.hpp b/proton-c/bindings/cpp/include/proton/io.hpp
index e559504..35a7223 100644
--- a/proton-c/bindings/cpp/include/proton/io.hpp
+++ b/proton-c/bindings/cpp/include/proton/io.hpp
@@ -21,6 +21,7 @@
*/
#include <proton/connection_engine.hpp>
+#include <proton/url.hpp>
namespace proton {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/link_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/link_options.hpp b/proton-c/bindings/cpp/include/proton/link_options.hpp
index f33b203..2eb145d 100644
--- a/proton-c/bindings/cpp/include/proton/link_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/link_options.hpp
@@ -170,7 +170,7 @@ class link_options {
proton_handler* handler() const;
class impl;
- pn_unique_ptr<impl> impl_;
+ internal::pn_unique_ptr<impl> impl_;
friend class link;
/// @endcond
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp b/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp
index 1e90583..4abe399 100644
--- a/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp
+++ b/proton-c/bindings/cpp/include/proton/pn_unique_ptr.hpp
@@ -20,13 +20,12 @@
*/
/// @cond INTERNAL
-/// XXX discuss where this gets exposed
-/// XXX decision - move to proton::internal and leave it undocumented
#include "proton/config.hpp"
#include <memory>
namespace proton {
+namespace internal {
/// A simple unique ownership pointer, used as a return value from
/// functions that transfer ownership to the caller.
@@ -61,8 +60,8 @@ template <class T> class pn_unique_ptr {
T* ptr_;
};
-/// @endcond
+}}
-}
+/// @endcond
#endif // UNIQUE_PTR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reactor.hpp b/proton-c/bindings/cpp/include/proton/reactor.hpp
deleted file mode 100644
index 4f8851d..0000000
--- a/proton-c/bindings/cpp/include/proton/reactor.hpp
+++ /dev/null
@@ -1,102 +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/object.hpp"
-#include "proton/duration.hpp"
-#include "proton/timestamp.hpp"
-
-struct pn_reactor_t;
-struct pn_io_t;
-
-namespace proton {
-
-class connection;
-class container;
-class acceptor;
-class url;
-class handler;
-class task;
-
-class reactor : public object<pn_reactor_t> {
- public:
- reactor(pn_reactor_t* r = 0) : object<pn_reactor_t>(r) {}
-
- /** Create a new reactor. */
- PN_CPP_EXTERN static reactor create();
-
- /** Open a connection to url and create a receiver with source=url.path() */
- PN_CPP_EXTERN acceptor listen(const proton::url &);
-
- /** Run the event loop, return when all connections and acceptors are closed. */
- PN_CPP_EXTERN void run();
-
- /** Start the reactor, you must call process() to process events */
- PN_CPP_EXTERN void start();
-
- /** Process events, return true if there are more events to process. */
- PN_CPP_EXTERN bool process();
-
- /** Stop the reactor, causes run() to return and process() to return false. */
- PN_CPP_EXTERN void stop();
-
- /// Identifier for the container
- PN_CPP_EXTERN std::string id() const;
-
- /// Get timeout, process() will return if there is no activity within the timeout.
- PN_CPP_EXTERN duration timeout();
-
- /// Set timeout, process() will return if there is no activity within the timeout.
- PN_CPP_EXTERN void timeout(duration timeout);
-
- PN_CPP_EXTERN timestamp mark();
- PN_CPP_EXTERN timestamp now();
-
- PN_CPP_EXTERN task schedule(int, pn_handler_t*);
-
- class connection connection(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;
-
- PN_CPP_EXTERN void wakeup();
- PN_CPP_EXTERN bool quiesced();
- PN_CPP_EXTERN void yield();
-
- friend class container_impl;
- friend class container_context;
-};
-
-}
-
-/// @endcond
-
-#endif // REACTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
index d7b720f..0d30d4c 100644
--- a/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
+++ b/proton-c/bindings/cpp/include/proton/reconnect_timer.hpp
@@ -26,8 +26,9 @@
/// XXX more discussion
#include "proton/export.hpp"
+#include "proton/duration.hpp"
+#include "proton/timestamp.hpp"
#include "proton/types.hpp"
-#include "proton/reactor.hpp"
#include <string>
namespace proton {
@@ -45,25 +46,23 @@ class reconnect_timer
PN_CPP_EXTERN void reset();
/** Obtain the timer's computed time to delay before attempting a reconnection attempt (in milliseconds). -1 means that the retry limit or timeout has been exceeded and reconnection attempts should cease. */
- PN_CPP_EXTERN int next_delay();
+ PN_CPP_EXTERN int next_delay(timestamp now);
private:
- int32_t first_delay_;
- int32_t max_delay_;
- int32_t increment_;
+ duration first_delay_;
+ duration max_delay_;
+ duration increment_;
bool doubling_;
int32_t max_retries_;
- int32_t timeout_;
+ duration timeout_;
int32_t retries_;
- int32_t next_delay_;
- pn_timestamp_t timeout_deadline_;
- reactor reactor_;
+ duration next_delay_;
+ timestamp timeout_deadline_;
friend class connector;
};
/// @endcond
-
}
#endif // PROTON_CPP_RECONNECT_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/include/proton/timestamp.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/timestamp.hpp b/proton-c/bindings/cpp/include/proton/timestamp.hpp
index 96a8166..00282dd 100644
--- a/proton-c/bindings/cpp/include/proton/timestamp.hpp
+++ b/proton-c/bindings/cpp/include/proton/timestamp.hpp
@@ -41,6 +41,7 @@ inline bool operator==(timestamp x, timestamp y) { return x.ms() == y.ms(); }
inline bool operator<(timestamp x, timestamp y) { return x.ms() < y.ms(); }
inline timestamp operator+(timestamp ts, duration d) { return timestamp(ts.ms() + d.ms()); }
+inline duration operator-(timestamp t0, timestamp t1) { return duration(t0.ms() - t1.ms()); }
inline timestamp operator+(duration d, timestamp ts) { return ts + d; }
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, timestamp);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/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
index e69559d..66b51a6 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -57,7 +57,6 @@ bool connector::transport_configured() { return transport_configured_; }
void connector::reconnect_timer(const class reconnect_timer &rt) {
delete reconnect_timer_;
reconnect_timer_ = new class reconnect_timer(rt);
- reconnect_timer_->reactor_ = connection_.container().reactor();
}
void connector::connect() {
@@ -98,7 +97,7 @@ void connector::on_transport_closed(proton_event &e) {
if (reconnect_timer_) {
e.connection().transport().unbind();
transport_configured_ = false;
- int delay = reconnect_timer_->next_delay();
+ int delay = reconnect_timer_->next_delay(timestamp::now());
if (delay >= 0) {
if (delay == 0) {
// log "Disconnected, reconnecting..."
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/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
index e61549e..86571ec 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -152,7 +152,7 @@ connection container_impl::connect(const proton::url &url, const connection_opti
pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : pn_ptr<pn_handler_t>();
connection conn(reactor_.connection(chandler.get()));
- pn_unique_ptr<connector> ctor(new connector(conn, opts));
+ internal::pn_unique_ptr<connector> ctor(new connector(conn, opts));
ctor->address(url); // TODO: url vector
connection_context& cc(connection_context::get(conn));
cc.handler.reset(ctor.release());
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp
index 049493e..cb098fc 100644
--- a/proton-c/bindings/cpp/src/container_impl.hpp
+++ b/proton-c/bindings/cpp/src/container_impl.hpp
@@ -30,7 +30,7 @@
#include "proton/handler.hpp"
#include "proton/link.hpp"
#include "proton/reactor.h"
-#include "proton/reactor.hpp"
+#include "reactor.hpp"
#include "proton_handler.hpp"
#include <string>
@@ -74,8 +74,8 @@ class container_impl
container& container_;
reactor reactor_;
proton_handler *handler_;
- pn_unique_ptr<proton_handler> override_handler_;
- pn_unique_ptr<proton_handler> flow_controller_;
+ internal::pn_unique_ptr<proton_handler> override_handler_;
+ internal::pn_unique_ptr<proton_handler> flow_controller_;
std::string id_;
id_generator id_gen_;
connection_options client_connection_options_;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
index ae4e9c1..c2b76f6 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -21,6 +21,7 @@
#include "contexts.hpp"
#include "msg.hpp"
+#include "reactor.hpp"
#include "proton/error.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
index 219a909..b4fcdba 100644
--- a/proton-c/bindings/cpp/src/contexts.hpp
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -33,6 +33,7 @@
struct pn_session_t;
struct pn_event_t;
+struct pn_reactor_t;
struct pn_record_t;
struct pn_acceptor_t;
@@ -87,7 +88,7 @@ class connection_context : public context {
message event_message; // re-used by messaging_adapter for performance.
id_generator link_gen; // Link name generator.
- pn_unique_ptr<proton_handler> handler;
+ internal::pn_unique_ptr<proton_handler> handler;
static connection_context& get(pn_connection_t *c) { return ref<connection_context>(id(c)); }
static connection_context& get(const connection& c) { return ref<connection_context>(id(c)); }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp
index 32e0423..c02b936 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.hpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp
@@ -61,7 +61,7 @@ class messaging_adapter : public proton_handler
bool auto_accept_;
bool auto_settle_;
bool peer_close_iserror_;
- pn_unique_ptr<proton_handler> flow_controller_;
+ internal::pn_unique_ptr<proton_handler> flow_controller_;
void create_helpers();
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/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
index 159eb94..62508ba 100644
--- a/proton-c/bindings/cpp/src/reactor.cpp
+++ b/proton-c/bindings/cpp/src/reactor.cpp
@@ -17,7 +17,8 @@
* under the License.
*/
-#include "proton/reactor.hpp"
+#include "reactor.hpp"
+
#include "proton/acceptor.hpp"
#include "proton/connection.hpp"
#include "proton/task.hpp"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/reactor.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reactor.hpp b/proton-c/bindings/cpp/src/reactor.hpp
new file mode 100644
index 0000000..4f8851d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/reactor.hpp
@@ -0,0 +1,102 @@
+#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/object.hpp"
+#include "proton/duration.hpp"
+#include "proton/timestamp.hpp"
+
+struct pn_reactor_t;
+struct pn_io_t;
+
+namespace proton {
+
+class connection;
+class container;
+class acceptor;
+class url;
+class handler;
+class task;
+
+class reactor : public object<pn_reactor_t> {
+ public:
+ reactor(pn_reactor_t* r = 0) : object<pn_reactor_t>(r) {}
+
+ /** Create a new reactor. */
+ PN_CPP_EXTERN static reactor create();
+
+ /** Open a connection to url and create a receiver with source=url.path() */
+ PN_CPP_EXTERN acceptor listen(const proton::url &);
+
+ /** Run the event loop, return when all connections and acceptors are closed. */
+ PN_CPP_EXTERN void run();
+
+ /** Start the reactor, you must call process() to process events */
+ PN_CPP_EXTERN void start();
+
+ /** Process events, return true if there are more events to process. */
+ PN_CPP_EXTERN bool process();
+
+ /** Stop the reactor, causes run() to return and process() to return false. */
+ PN_CPP_EXTERN void stop();
+
+ /// Identifier for the container
+ PN_CPP_EXTERN std::string id() const;
+
+ /// Get timeout, process() will return if there is no activity within the timeout.
+ PN_CPP_EXTERN duration timeout();
+
+ /// Set timeout, process() will return if there is no activity within the timeout.
+ PN_CPP_EXTERN void timeout(duration timeout);
+
+ PN_CPP_EXTERN timestamp mark();
+ PN_CPP_EXTERN timestamp now();
+
+ PN_CPP_EXTERN task schedule(int, pn_handler_t*);
+
+ class connection connection(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;
+
+ PN_CPP_EXTERN void wakeup();
+ PN_CPP_EXTERN bool quiesced();
+ PN_CPP_EXTERN void yield();
+
+ friend class container_impl;
+ friend class container_context;
+};
+
+}
+
+/// @endcond
+
+#endif // REACTOR_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d758832d/proton-c/bindings/cpp/src/reconnect_timer.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_timer.cpp b/proton-c/bindings/cpp/src/reconnect_timer.cpp
index 245778b..04a4a94 100644
--- a/proton-c/bindings/cpp/src/reconnect_timer.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_timer.cpp
@@ -20,7 +20,6 @@
*/
#include "proton/reconnect_timer.hpp"
-#include "proton/reactor.hpp"
#include "proton/error.hpp"
#include "msg.hpp"
#include "proton/types.h"
@@ -31,8 +30,8 @@ namespace proton {
reconnect_timer::reconnect_timer(uint32_t first, int32_t max, uint32_t increment,
bool doubling, int32_t max_retries, int32_t timeout) :
first_delay_(first), max_delay_(max), increment_(increment), doubling_(doubling),
- max_retries_(max_retries), timeout_(timeout), retries_(0), next_delay_(-1), timeout_deadline_(0),
- reactor_(0) {}
+ max_retries_(max_retries), timeout_(timeout), retries_(0), next_delay_(-1), timeout_deadline_(0)
+ {}
void reconnect_timer::reset() {
retries_ = 0;
@@ -40,30 +39,27 @@ void reconnect_timer::reset() {
timeout_deadline_ = 0;
}
-int reconnect_timer::next_delay() {
+int reconnect_timer::next_delay(timestamp now) {
retries_++;
if (max_retries_ >= 0 && retries_ > max_retries_)
return -1;
- if (!reactor_)
- throw error(MSG("reconnect timer missing reactor reference"));
- pn_timestamp_t now = reactor_.now().ms();
if (retries_ == 1) {
- if (timeout_ >= 0)
+ if (timeout_ >= duration(0))
timeout_deadline_ = now + timeout_;
next_delay_ = first_delay_;
} else if (retries_ == 2) {
- next_delay_ += increment_;
+ next_delay_ = next_delay_ + increment_;
} else {
- next_delay_ += doubling_ ? next_delay_ : increment_;
+ next_delay_ = next_delay_ + ( doubling_ ? next_delay_ : increment_ );
}
- if (timeout_deadline_ && now >= timeout_deadline_)
+ if (timeout_deadline_ != timestamp(0) && now >= timeout_deadline_)
return -1;
- if (max_delay_ >= 0 && next_delay_ > max_delay_)
+ if (max_delay_ >= duration(0) && next_delay_ > max_delay_)
next_delay_ = max_delay_;
- if (timeout_deadline_ && (now + next_delay_ > timeout_deadline_))
+ if (timeout_deadline_ != timestamp(0) && (now + next_delay_ > timeout_deadline_))
next_delay_ = timeout_deadline_ - now;
- return next_delay_;
+ return next_delay_.ms();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org