summaryrefslogtreecommitdiff
path: root/cpp/src/framing/ChannelAdapter.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-04-05 19:16:09 +0000
committerAlan Conway <aconway@apache.org>2007-04-05 19:16:09 +0000
commitbb79efff2408de5f6cd66089cde8b8a82cc80cc2 (patch)
tree9d9c72158da31cebdd7ee538a11951b240922065 /cpp/src/framing/ChannelAdapter.cpp
parent2a1e4c9663ff0725c061248a96ebab763678fdd6 (diff)
downloadqpid-python-bb79efff2408de5f6cd66089cde8b8a82cc80cc2.tar.gz
* Exteneded use of shared pointers frame bodies across all send() commands.
* tests/Makefile.am: added check-unit target to run just unit tests. * Introduced make_shared_ptr convenience function for wrapping plain pointers with shared_ptr. * cpp/src/client/ClientChannel.h,cpp (sendsendAndReceive,sendAndReceiveSync): Pass shared_ptr instead of raw ptr to fix memory problems. Updated the following files to use make_shared_ptr - src/client/BasicMessageChannel.cpp - src/client/ClientConnection.cpp * src/client/MessageMessageChannel.cpp: implemented 0-9 message.get. * src/framing/Correlator.h,cpp: Allow request sender to register actions to take when the correlated response arrives. * cpp/src/tests/FramingTest.cpp: Added Correlator tests. * src/framing/ChannelAdapter.h,cpp: use Correlator to dispatch response actions. * cpp/src/shared_ptr.h (make_shared_ptr): Convenience function to make a shared pointer from a raw pointer. * cpp/src/tests/ClientChannelTest.cpp: Added message.get test. * cpp/src/tests/Makefile.am (check-unit): Added test-unit target to run unit tests. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@525932 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/framing/ChannelAdapter.cpp')
-rw-r--r--cpp/src/framing/ChannelAdapter.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/cpp/src/framing/ChannelAdapter.cpp b/cpp/src/framing/ChannelAdapter.cpp
index 99a14f08fb..d16934a857 100644
--- a/cpp/src/framing/ChannelAdapter.cpp
+++ b/cpp/src/framing/ChannelAdapter.cpp
@@ -35,15 +35,19 @@ void ChannelAdapter::init(
version = v;
}
-RequestId ChannelAdapter::send(AMQBody::shared_ptr body) {
- RequestId result = 0;
+RequestId ChannelAdapter::send(
+ shared_ptr<AMQBody> body, Correlator::Action action)
+{
+ RequestId requestId = 0;
assertChannelOpen();
switch (body->type()) {
case REQUEST_BODY: {
AMQRequestBody::shared_ptr request =
boost::shared_polymorphic_downcast<AMQRequestBody>(body);
requester.sending(request->getData());
- result = request->getData().requestId;
+ requestId = request->getData().requestId;
+ if (!action.empty())
+ correlator.request(requestId, action);
break;
}
case RESPONSE_BODY: {
@@ -52,9 +56,10 @@ RequestId ChannelAdapter::send(AMQBody::shared_ptr body) {
responder.sending(response->getData());
break;
}
+ // No action required for other body types.
}
out->send(new AMQFrame(getVersion(), getId(), body));
- return result;
+ return requestId;
}
void ChannelAdapter::handleRequest(AMQRequestBody::shared_ptr request) {
@@ -66,10 +71,15 @@ void ChannelAdapter::handleRequest(AMQRequestBody::shared_ptr request) {
void ChannelAdapter::handleResponse(AMQResponseBody::shared_ptr response) {
assertMethodOk(*response);
- // TODO aconway 2007-01-30: Consider a response handled on receipt.
- // Review - any cases where this is not the case?
AMQResponseBody::Data& responseData = response->getData();
+
+ // FIXME aconway 2007-04-05: processed should be last
+ // but causes problems with InProcessBroker tests because
+ // we execute client code in handleMethod.
+ // Need to introduce a queue & 2 threads for inprocess.
requester.processed(responseData);
+ // FIXME aconway 2007-04-04: exception handling.
+ correlator.response(response);
handleMethod(response);
}