From 49c7a491c98c26fe7d4f017a7ba655dfc029278c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 16 Aug 2007 20:12:33 +0000 Subject: AMQBodies are no longer allocated on the heap and passed with shared_ptr. AMQFrame contains a boost::variant of AMQHeaderBody,AMQContentBody, AMQHeatbeatBody, and MethodHolder. A variant is basically a type-safe union, it can allocate any of the types in-place. MethodHolder contains a Blob, a less sophisticated kind of variant, which can contain any of the concrete method body types. Using variants for all the method types causes outrageous compile times and bloated library symbol names. Blob lacks some of the finer features of variant and needs help from generated code. For now both are hidden to the rest of the code base behind AMQFrame and MethodBody classes so if/when we decide to settle on just one "variant" type solution we can do so. This commit touches nearly 100 files, mostly converting method signatures with shared_ptr to FooBody* or FooBody&, and converting stored shared_ptr to AMQFrame and share_ptr to MethodHolder. There is one outstanding client memory leak, which I will fix in my next commit. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@566822 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/BrokerChannelTest.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'cpp/src/tests/BrokerChannelTest.cpp') diff --git a/cpp/src/tests/BrokerChannelTest.cpp b/cpp/src/tests/BrokerChannelTest.cpp index eb67601875..6c9b910637 100644 --- a/cpp/src/tests/BrokerChannelTest.cpp +++ b/cpp/src/tests/BrokerChannelTest.cpp @@ -31,6 +31,7 @@ #include "MockChannel.h" #include "qpid/broker/Connection.h" #include "qpid/framing/ProtocolInitiation.h" +#include "qpid/framing/ConnectionStartBody.h" #include using namespace boost; @@ -233,18 +234,18 @@ class BrokerChannelTest : public CppUnit::TestCase Queue::shared_ptr queue(new Queue("my_queue")); exchange->bind(queue, "", 0); - AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC)); + AMQHeaderBody header(BASIC); uint64_t contentSize(0); for (int i = 0; i < 3; i++) { contentSize += data[i].size(); } - header->setContentSize(contentSize); + header.setContentSize(contentSize); channel.handlePublish(msg); - channel.handleHeader(header); + channel.handleHeader(&header); for (int i = 0; i < 3; i++) { - AMQContentBody::shared_ptr body(new AMQContentBody(data[i])); - channel.handleContent(body); + AMQContentBody body(data[i]); + channel.handleContent(&body); } Message::shared_ptr msg2 = queue->dequeue(); CPPUNIT_ASSERT_EQUAL(msg, msg2.get()); @@ -312,8 +313,7 @@ class BrokerChannelTest : public CppUnit::TestCase //there will always be a connection-start frame CPPUNIT_ASSERT_EQUAL((size_t) 1, handler.frames.size()); CPPUNIT_ASSERT_EQUAL(ChannelId(0), handler.frames[0].getChannel()); - CPPUNIT_ASSERT(dynamic_cast( - handler.frames[0].getBody().get())); + CPPUNIT_ASSERT(dynamic_cast(handler.frames[0].getBody())); const string data("abcdefghijklmn"); @@ -340,17 +340,17 @@ class BrokerChannelTest : public CppUnit::TestCase { BasicMessage* msg = new BasicMessage( 0, exchange, routingKey, false, false); - AMQHeaderBody::shared_ptr header(new AMQHeaderBody(BASIC)); - header->setContentSize(contentSize); - msg->setHeader(header); + AMQHeaderBody header(BASIC); + header.setContentSize(contentSize); + msg->setHeader(&header); msg->getHeaderProperties()->setMessageId(messageId); return msg; } void addContent(Message::shared_ptr msg, const string& data) { - AMQContentBody::shared_ptr body(new AMQContentBody(data)); - msg->addContent(body); + AMQContentBody body(data); + msg->addContent(&body); } }; -- cgit v1.2.1