diff options
author | Alan Conway <aconway@apache.org> | 2008-01-29 20:39:26 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-01-29 20:39:26 +0000 |
commit | 1fd398c1c0b78ce48d3b540698cfbf085e5ff8dd (patch) | |
tree | 0665758138bb485b43e5be7190ab0f5ec47c0420 /cpp/src | |
parent | 5cc7ee2784983f4875d1b8eca2db75b431e91a6f (diff) | |
download | qpid-python-1fd398c1c0b78ce48d3b540698cfbf085e5ff8dd.tar.gz |
Added Observer to SessionManager for cluster use.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@616511 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/broker/SessionManager.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/broker/SessionManager.h | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/cpp/src/qpid/broker/SessionManager.cpp b/cpp/src/qpid/broker/SessionManager.cpp index 1d5f9ebada..aadb2b9004 100644 --- a/cpp/src/qpid/broker/SessionManager.cpp +++ b/cpp/src/qpid/broker/SessionManager.cpp @@ -50,6 +50,8 @@ std::auto_ptr<SessionState> SessionManager::open( std::auto_ptr<SessionState> session( new SessionState(*this, h, timeout_, ack)); active.insert(session->getId()); + for_each(observers.begin(), observers.end(), + boost::bind(&Observer::opened, _1,boost::ref(*session))); return session; } @@ -102,4 +104,8 @@ void SessionManager::eraseExpired() { } } +void SessionManager::add(const intrusive_ptr<Observer>& o) { + observers.push_back(o); +} + }} // namespace qpid::broker diff --git a/cpp/src/qpid/broker/SessionManager.h b/cpp/src/qpid/broker/SessionManager.h index fa7262252d..bb61f5a8be 100644 --- a/cpp/src/qpid/broker/SessionManager.h +++ b/cpp/src/qpid/broker/SessionManager.h @@ -25,6 +25,7 @@ #include <qpid/framing/Uuid.h> #include <qpid/sys/Time.h> #include <qpid/sys/Mutex.h> +#include <qpid/RefCounted.h> #include <boost/noncopyable.hpp> #include <boost/ptr_container/ptr_vector.hpp> @@ -44,8 +45,17 @@ class SessionHandler; */ class SessionManager : private boost::noncopyable { public: + /** + * Observer notified of SessionManager events. + */ + struct Observer : public RefCounted { + virtual void opened(SessionState&) {} + }; + SessionManager(uint32_t ack); + ~SessionManager(); + /** Open a new active session, caller takes ownership */ std::auto_ptr<SessionState> open(SessionHandler& h, uint32_t timeout_); @@ -59,9 +69,13 @@ class SessionManager : private boost::noncopyable { */ std::auto_ptr<SessionState> resume(const framing::Uuid&); + /** Add an Observer. */ + void add(const intrusive_ptr<Observer>&); + private: typedef boost::ptr_vector<SessionState> Suspended; typedef std::set<framing::Uuid> Active; + typedef std::vector<intrusive_ptr<Observer> > Observers; void erase(const framing::Uuid&); void eraseExpired(); @@ -70,6 +84,7 @@ class SessionManager : private boost::noncopyable { Suspended suspended; Active active; uint32_t ack; + Observers observers; friend class SessionState; // removes deleted sessions from active set. }; |