diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2012-12-21 17:04:33 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2012-12-21 17:04:33 +0000 |
| commit | f5431bb215c107c1967842cfeb6814cfd3a866a9 (patch) | |
| tree | cb7b17c8153b84e1c1db6c0331dcc51a1eb22cb5 /cpp/src/qpid/management | |
| parent | fd54c5f98193aa0a1b2064a13cec094d1be9dfe3 (diff) | |
| download | qpid-python-f5431bb215c107c1967842cfeb6814cfd3a866a9.tar.gz | |
NO-JIRA: Removed Timer.h out of the chain of header files included by Broker.h
(since that is widely included) to avoid unnecessary recompilation
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1425037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/management')
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.cpp | 46 | ||||
| -rw-r--r-- | cpp/src/qpid/management/ManagementAgent.h | 13 |
2 files changed, 34 insertions, 25 deletions
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp index 991dac9139..9be07d1ca2 100644 --- a/cpp/src/qpid/management/ManagementAgent.cpp +++ b/cpp/src/qpid/management/ManagementAgent.cpp @@ -33,6 +33,7 @@ #include "qpid/framing/FieldValue.h" #include "qpid/broker/amqp_0_10/MessageTransfer.h" #include "qpid/sys/Time.h" +#include "qpid/sys/Timer.h" #include "qpid/sys/Thread.h" #include "qpid/sys/PollableQueue.h" #include "qpid/broker/ConnectionState.h" @@ -47,6 +48,9 @@ #include <sstream> #include <typeinfo> +#include <boost/bind.hpp> +#include <boost/function.hpp> + namespace qpid { namespace management { @@ -92,6 +96,32 @@ struct ScopedManagementContext setManagementExecutionContext(0); } }; + +typedef boost::function0<void> FireFunction; +struct Periodic : public qpid::sys::TimerTask +{ + FireFunction fireFunction; + qpid::sys::Timer* timer; + + Periodic (FireFunction f, qpid::sys::Timer* t, uint32_t seconds); + virtual ~Periodic (); + void fire (); +}; + +Periodic::Periodic (FireFunction f, qpid::sys::Timer* t, uint32_t _seconds) + : TimerTask(sys::Duration((_seconds ? _seconds : 1) * sys::TIME_SEC), + "ManagementAgent::periodicProcessing"), + fireFunction(f), timer(t) {} + +Periodic::~Periodic() {} + +void Periodic::fire() +{ + setupNextFire(); + timer->add(this); + fireFunction(); +} + } @@ -171,7 +201,7 @@ void ManagementAgent::configure(const string& _dataDir, bool _publish, uint16_t new EventQueue(boost::bind(&ManagementAgent::sendEvents, this, _1), broker->getPoller())); sendQueue->start(); timer = &broker->getTimer(); - timer->add(new Periodic(*this, interval)); + timer->add(new Periodic(boost::bind(&ManagementAgent::periodicProcessing, this), timer, interval)); // Get from file or generate and save to file. if (dataDir.empty()) @@ -415,20 +445,6 @@ void ManagementAgent::raiseEvent(const ManagementEvent& event, severity_t severi } } -ManagementAgent::Periodic::Periodic (ManagementAgent& _agent, uint32_t _seconds) - : TimerTask(sys::Duration((_seconds ? _seconds : 1) * sys::TIME_SEC), - "ManagementAgent::periodicProcessing"), - agent(_agent) {} - -ManagementAgent::Periodic::~Periodic() {} - -void ManagementAgent::Periodic::fire() -{ - setupNextFire(); - agent.timer->add(this); - agent.periodicProcessing(); -} - void ManagementAgent::clientAdded (const string& routingKey) { sys::Mutex::ScopedLock lock(userLock); diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h index 48ed2f7566..0953493388 100644 --- a/cpp/src/qpid/management/ManagementAgent.h +++ b/cpp/src/qpid/management/ManagementAgent.h @@ -26,7 +26,6 @@ #include "qpid/broker/Exchange.h" #include "qpid/framing/Uuid.h" #include "qpid/sys/Mutex.h" -#include "qpid/sys/Timer.h" #include "qpid/broker/ConnectionToken.h" #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" @@ -47,6 +46,9 @@ namespace qpid { namespace broker { class ConnectionState; } +namespace sys { +class Timer; +} namespace management { class ManagementAgent @@ -176,15 +178,6 @@ public: void importDeletedObjects( const DeletedObjectList& inList ); private: - struct Periodic : public qpid::sys::TimerTask - { - ManagementAgent& agent; - - Periodic (ManagementAgent& agent, uint32_t seconds); - virtual ~Periodic (); - void fire (); - }; - // Storage for tracking remote management agents, attached via the client // management agent API. // |
