diff options
author | Andrew Stitcher <astitcher@apache.org> | 2010-04-08 04:53:26 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2010-04-08 04:53:26 +0000 |
commit | b799ad84fe13f0573a3423b2097c8931859d16eb (patch) | |
tree | 4b6b9ac5a2e929a93b7fc9695e9d6b3bfd7a52f9 | |
parent | 6d1532b40eae7ca08a44d8b5cdee22663c939be5 (diff) | |
download | qpid-python-b799ad84fe13f0573a3423b2097c8931859d16eb.tar.gz |
Improved fix for to create client library Poller. Improved because it
is now created at first need rather than library load.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@931781 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/client/Connection.cpp | 5 | ||||
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 16 | ||||
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.h | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index 32a01b2c40..d8ffb6d9e1 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/cpp/src/qpid/client/Connection.cpp @@ -45,7 +45,10 @@ using namespace qpid::sys; namespace qpid { namespace client { -Connection::Connection() : version(framing::highestProtocolVersion) {} +Connection::Connection() : version(framing::highestProtocolVersion) +{ + ConnectionImpl::init(); +} Connection::~Connection() {} diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index 05a781c2d9..b6043518e8 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -137,15 +137,6 @@ IOThread& theIO() { return io; } -// Bring theIO into existence on library load rather than first use. -// This avoids it being destroyed whilst something in the main program -// still exists -struct InitAtLoad { - InitAtLoad() { - (void) theIO(); - } -} init; - class HeartbeatTask : public TimerTask { TimeoutHandler& timeout; @@ -164,6 +155,13 @@ public: } +// Ensure the IO threads exist: +// This needs to be called in the Connection constructor +// so that they will still exist at last connection destruction +void ConnectionImpl::init() { + (void) theIO(); +} + ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSettings& settings) : Bounds(settings.maxFrameSize * settings.bounds), handler(settings, v), diff --git a/cpp/src/qpid/client/ConnectionImpl.h b/cpp/src/qpid/client/ConnectionImpl.h index 2b32e1ccf0..1d88fcaf99 100644 --- a/cpp/src/qpid/client/ConnectionImpl.h +++ b/cpp/src/qpid/client/ConnectionImpl.h @@ -50,6 +50,7 @@ class ConnectionImpl : public Bounds, public boost::enable_shared_from_this<ConnectionImpl> { + friend class Connection; typedef std::map<uint16_t, boost::weak_ptr<SessionImpl> > SessionMap; static const uint16_t NEXT_CHANNEL; @@ -65,7 +66,8 @@ class ConnectionImpl : public Bounds, template <class F> void closeInternal(const F&); - void incoming(framing::AMQFrame& frame); + static void init(); + void incoming(framing::AMQFrame& frame); void closed(uint16_t, const std::string&); void idleOut(); void idleIn(); |