From b13398b09dcd64b32cdde09ed61a1ecc7a10e5a9 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Tue, 15 Apr 2014 13:18:32 +0200 Subject: [PATCH] setTimeout function removed from connection handler, the finalize and error callbacks are called right away if installed on an object that already is in an error state --- include/connectionhandler.h | 16 ---------------- include/deferred.h | 6 ++++++ src/channelimpl.cpp | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/connectionhandler.h b/include/connectionhandler.h index 0fa28ee..59c551e 100644 --- a/include/connectionhandler.h +++ b/include/connectionhandler.h @@ -21,22 +21,6 @@ namespace AMQP { class ConnectionHandler { public: - /** - * Set a function to be executed after a given timeout. - * - * This function is not strictly necessary to implement. If you - * do not implement it, certain methods that fail immediately - * will not be reported. - * - * @param connection the connection that needs the timeout - * @param timeout number of seconds to wait - * @param callback function to execute once time runs out - * - * - * @todo this one should be removed - */ - virtual void setTimeout(Connection *connection, double seconds, const std::function& callback) {} - /** * Method that is called when data needs to be sent over the network * diff --git a/include/deferred.h b/include/deferred.h index 897c36a..d8fd257 100644 --- a/include/deferred.h +++ b/include/deferred.h @@ -205,6 +205,9 @@ public: { // store callback _errorCallback = callback; + + // if the object is already in a failed state, we call the callback right away + if (_failed) callback("Frame could not be sent"); // allow chaining return *this; @@ -230,6 +233,9 @@ public: // store callback _finalizeCallback = callback; + // if the object is already in a failed state, we call the callback right away + if (_failed) callback(); + // allow chaining return *this; } diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index 27c1bea..31cbec1 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -134,7 +134,7 @@ void ChannelImpl::reportErrors(bool force) Monitor monitor(this); // report the error - auto *next = _oldestCallback->reportError("Frame could not be sent"); + auto *next = _oldestCallback->reportError("Frame could not be delivered"); // leap out if object is no longer valid after the callback was called if (!monitor.valid()) return;