diff options
author | Alan Conway <aconway@apache.org> | 2007-03-27 15:36:39 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-03-27 15:36:39 +0000 |
commit | 847ee577e23fbdd2175709a08a7160e8b2c1f464 (patch) | |
tree | e4962c5246c91a08ef635f2c68e06b82cfb100ee /cpp/lib/client/ResponseHandler.h | |
parent | fb14a2042dd5bdae5a5c79b8cd4f1ad87e59bee1 (diff) | |
download | qpid-python-847ee577e23fbdd2175709a08a7160e8b2c1f464.tar.gz |
Refactored client::Message to be independent of all Basic class concepts
and client::IncomingMessage to handle 0-9 style references and appends.
* cpp/lib/client/ClientMessage.cpp: Made independent of Basic class.
* cpp/lib/client/IncomingMessage.cpp: Refactored to handle references/appends.
* cpp/lib/client/BasicMessageChannel.cpp: Refactored to use new IncomingMessage
Thread safety fixes:
* cpp/lib/client/ResponseHandler.h: Remove stateful functions.
* cpp/lib/client/ClientChannel.cpp: use new ResponseHandler interface.
Minor cleanup:
* cpp/lib/common/framing/BasicHeaderProperties.cpp: use DeliveryMode enum.
* cpp/tests/HeaderTest.cpp: use DeliveryMode enum.
* cpp/tests/MessageTest.cpp: use DeliveryMode enum.
* cpp/lib/common/shared_ptr.h: #include <boost/cast.hpp> for convenience.
* cpp/lib/common/sys/ThreadSafeQueue.h: Changed "stop" "shutdown"
* cpp/lib/common/sys/ProducerConsumer.h: Changed "stop" "shutdown"
* cpp/tests/ClientChannelTest.cpp (TestCase): Removed debug couts.
* cpp/tests/setup: valgrind --demangle=yes by default.
* cpp/tests/topictest: sleep to hack around startup race.
* cpp/lib/broker/BrokerQueue.cpp (configure): Fixed memory leak.
Removed/updated FIXME comments in:
* cpp/lib/broker/BrokerMessage.cpp:
* cpp/lib/broker/BrokerMessageBase.h:
* cpp/lib/broker/InMemoryContent.cpp:
* cpp/lib/common/framing/MethodContext.h:
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@522956 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/client/ResponseHandler.h')
-rw-r--r-- | cpp/lib/client/ResponseHandler.h | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/cpp/lib/client/ResponseHandler.h b/cpp/lib/client/ResponseHandler.h index d28048c3d3..500166144d 100644 --- a/cpp/lib/client/ResponseHandler.h +++ b/cpp/lib/client/ResponseHandler.h @@ -18,51 +18,58 @@ * under the License. * */ -#include <string> - -#include <framing/amqp_framing.h> // FIXME aconway 2007-02-01: #include cleanup. +#include "shared_ptr.h" #include <sys/Monitor.h> #ifndef _ResponseHandler_ #define _ResponseHandler_ namespace qpid { + +namespace framing { +class AMQMethodBody; +} + namespace client { /** * Holds a response from the broker peer for the client. */ class ResponseHandler{ + typedef shared_ptr<framing::AMQMethodBody> MethodPtr; bool waiting; - qpid::framing::AMQMethodBody::shared_ptr response; - qpid::sys::Monitor monitor; + bool shutdownFlag; + MethodPtr response; + sys::Monitor monitor; public: ResponseHandler(); ~ResponseHandler(); - - bool isWaiting(){ return waiting; } - framing::AMQMethodBody::shared_ptr getResponse(); - void waitForResponse(); - - void signalResponse(framing::AMQMethodBody::shared_ptr response); - void expect();//must be called before calling receive - bool validate(framing::ClassId, framing::MethodId); - void receive(framing::ClassId, framing::MethodId); + /** Is a response expected? */ + bool isWaiting(); - framing::RequestId getRequestId(); + /** Provide a response to the waiting thread */ + void signalResponse(MethodPtr response); - template <class BodyType> bool validate() { - return validate(BodyType::CLASS_ID, BodyType::METHOD_ID); - } - template <class BodyType> void receive() { - receive(BodyType::CLASS_ID, BodyType::METHOD_ID); + /** Indicate a message is expected. */ + void expect(); + + /** Wait for a response. */ + MethodPtr receive(); + + /** Wait for a specific response. */ + MethodPtr receive(framing::ClassId, framing::MethodId); + + /** Template version of receive returns typed pointer. */ + template <class BodyType> + shared_ptr<BodyType> receive() { + return shared_polymorphic_downcast<BodyType>( + receive(BodyType::CLASS_ID, BodyType::METHOD_ID)); } }; -} -} +}} #endif |