diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am
index f526479..f8093ba 100644
--- a/lib/cpp/Makefile.am
+++ b/lib/cpp/Makefile.am
@@ -105,6 +105,7 @@
 include_thriftdir = $(includedir)/thrift
 include_thrift_HEADERS = \
                          $(top_builddir)/config.h \
+	                 src/TDispatchProcessor.h \
                          src/Thrift.h \
                          src/TReflectionLocal.h \
                          src/TProcessor.h \
@@ -178,6 +179,7 @@
 include_asyncdir = $(include_thriftdir)/async
 include_async_HEADERS = \
                      src/async/TAsyncChannel.h \
+                     src/async/TAsyncDispatchProcessor.h \
                      src/async/TAsyncProcessor.h \
                      src/async/TAsyncBufferProcessor.h \
                      src/async/TAsyncProtocolProcessor.h \
diff --git a/lib/cpp/src/TDispatchProcessor.h b/lib/cpp/src/TDispatchProcessor.h
new file mode 100644
index 0000000..f98751b
--- /dev/null
+++ b/lib/cpp/src/TDispatchProcessor.h
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#ifndef _THRIFT_TDISPATCHPROCESSOR_H_
+#define _THRIFT_TDISPATCHPROCESSOR_H_ 1
+
+#include "TProcessor.h"
+
+namespace apache { namespace thrift {
+
+/**
+ * TDispatchProcessor is a helper class to parse the message header then call
+ * another function to dispatch based on the function name.
+ *
+ * Subclasses must implement dispatchCall() to dispatch on the function name.
+ */
+template <class Protocol_>
+class TDispatchProcessorT : public TProcessor {
+ public:
+  virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
+                       boost::shared_ptr<protocol::TProtocol> out,
+                       void* connectionContext) {
+    protocol::TProtocol* inRaw = in.get();
+    protocol::TProtocol* outRaw = out.get();
+
+    // Try to dynamic cast to the template protocol type
+    Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw);
+    Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw);
+    if (specificIn && specificOut) {
+      return processFast(specificIn, specificOut, connectionContext);
+    }
+
+    // Log the fact that we have to use the slow path
+    T_GENERIC_PROTOCOL(this, inRaw, specificIn);
+    T_GENERIC_PROTOCOL(this, outRaw, specificOut);
+
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    inRaw->readMessageBegin(fname, mtype, seqid);
+
+    // If this doesn't look like a valid call, log an error and return false so
+    // that the server will close the connection.
+    //
+    // (The old generated processor code used to try to skip a T_STRUCT and
+    // continue.  However, that seems unsafe.)
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      return false;
+    }
+
+    return this->dispatchCall(inRaw, outRaw, fname, seqid, connectionContext);
+  }
+
+ protected:
+  bool processFast(Protocol_* in, Protocol_* out, void* connectionContext) {
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    in->readMessageBegin(fname, mtype, seqid);
+
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      return false;
+    }
+
+    return this->dispatchCallTemplated(in, out, fname,
+                                       seqid, connectionContext);
+  }
+
+  /**
+   * dispatchCall() methods must be implemented by subclasses
+   */
+  virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in,
+                            apache::thrift::protocol::TProtocol* out,
+                            const std::string& fname, int32_t seqid,
+                            void* callContext) = 0;
+
+  virtual bool dispatchCallTemplated(Protocol_* in, Protocol_* out,
+                                     const std::string& fname, int32_t seqid,
+                                     void* callContext) = 0;
+};
+
+/**
+ * Non-templatized version of TDispatchProcessor, that doesn't bother trying to
+ * perform a dynamic_cast.
+ */
+class TDispatchProcessor : public TProcessor {
+ public:
+  virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
+                       boost::shared_ptr<protocol::TProtocol> out,
+                       void* connectionContext) {
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    in->readMessageBegin(fname, mtype, seqid);
+
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      return false;
+    }
+
+    return dispatchCall(in.get(), out.get(), fname, seqid, connectionContext);
+  }
+
+ protected:
+  virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in,
+                            apache::thrift::protocol::TProtocol* out,
+                            const std::string& fname, int32_t seqid,
+                            void* callContext) = 0;
+};
+
+// Specialize TDispatchProcessorT for TProtocol and TDummyProtocol just to use
+// the generic TDispatchProcessor.
+template <>
+class TDispatchProcessorT<protocol::TDummyProtocol> :
+  public TDispatchProcessor {};
+template <>
+class TDispatchProcessorT<protocol::TProtocol> :
+  public TDispatchProcessor {};
+
+}} // apache::thrift
+
+#endif // _THRIFT_TDISPATCHPROCESSOR_H_
diff --git a/lib/cpp/src/async/TAsyncDispatchProcessor.h b/lib/cpp/src/async/TAsyncDispatchProcessor.h
new file mode 100644
index 0000000..9427a32
--- /dev/null
+++ b/lib/cpp/src/async/TAsyncDispatchProcessor.h
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#ifndef _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_
+#define _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_ 1
+
+#include "TAsyncProcessor.h"
+
+namespace apache { namespace thrift { namespace async {
+
+/**
+ * TAsyncDispatchProcessor is a helper class to parse the message header then
+ * call another function to dispatch based on the function name.
+ *
+ * Subclasses must implement dispatchCall() to dispatch on the function name.
+ */
+template <class Protocol_>
+class TAsyncDispatchProcessorT : public TAsyncProcessor {
+ public:
+  virtual void process(std::tr1::function<void(bool success)> _return,
+                       boost::shared_ptr<protocol::TProtocol> in,
+                       boost::shared_ptr<protocol::TProtocol> out) {
+    protocol::TProtocol* inRaw = in.get();
+    protocol::TProtocol* outRaw = out.get();
+
+    // Try to dynamic cast to the template protocol type
+    Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw);
+    Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw);
+    if (specificIn && specificOut) {
+      return processFast(_return, specificIn, specificOut);
+    }
+
+    // Log the fact that we have to use the slow path
+    T_GENERIC_PROTOCOL(this, inRaw, specificIn);
+    T_GENERIC_PROTOCOL(this, outRaw, specificOut);
+
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    inRaw->readMessageBegin(fname, mtype, seqid);
+
+    // If this doesn't look like a valid call, log an error and return false so
+    // that the server will close the connection.
+    //
+    // (The old generated processor code used to try to skip a T_STRUCT and
+    // continue.  However, that seems unsafe.)
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      _return(false);
+      return;
+    }
+
+    return this->dispatchCall(_return, inRaw, outRaw, fname, seqid);
+  }
+
+  void processFast(std::tr1::function<void(bool success)> _return,
+                   Protocol_* in, Protocol_* out) {
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    in->readMessageBegin(fname, mtype, seqid);
+
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      _return(false);
+      return;
+    }
+
+    return this->dispatchCallTemplated(_return, in, out, fname, seqid);
+  }
+
+  virtual void dispatchCall(std::tr1::function<void(bool ok)> _return,
+                            apache::thrift::protocol::TProtocol* in,
+                            apache::thrift::protocol::TProtocol* out,
+                            const std::string& fname, int32_t seqid) = 0;
+
+  virtual void dispatchCallTemplated(std::tr1::function<void(bool ok)> _return,
+                                     Protocol_* in, Protocol_* out,
+                                     const std::string& fname,
+                                     int32_t seqid) = 0;
+};
+
+/**
+ * Non-templatized version of TAsyncDispatchProcessor,
+ * that doesn't bother trying to perform a dynamic_cast.
+ */
+class TAsyncDispatchProcessor : public TAsyncProcessor {
+ public:
+  virtual void process(std::tr1::function<void(bool success)> _return,
+                       boost::shared_ptr<protocol::TProtocol> in,
+                       boost::shared_ptr<protocol::TProtocol> out) {
+    protocol::TProtocol* inRaw = in.get();
+    protocol::TProtocol* outRaw = out.get();
+
+    std::string fname;
+    protocol::TMessageType mtype;
+    int32_t seqid;
+    inRaw->readMessageBegin(fname, mtype, seqid);
+
+    // If this doesn't look like a valid call, log an error and return false so
+    // that the server will close the connection.
+    //
+    // (The old generated processor code used to try to skip a T_STRUCT and
+    // continue.  However, that seems unsafe.)
+    if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) {
+      GlobalOutput.printf("received invalid message type %d from client",
+                          mtype);
+      _return(false);
+      return;
+    }
+
+    return dispatchCall(_return, inRaw, outRaw, fname, seqid);
+  }
+
+  virtual void dispatchCall(std::tr1::function<void(bool ok)> _return,
+                            apache::thrift::protocol::TProtocol* in,
+                            apache::thrift::protocol::TProtocol* out,
+                            const std::string& fname, int32_t seqid) = 0;
+};
+
+// Specialize TAsyncDispatchProcessorT for TProtocol and TDummyProtocol just to
+// use the generic TDispatchProcessor.
+template <>
+class TAsyncDispatchProcessorT<protocol::TDummyProtocol> :
+  public TAsyncDispatchProcessor {};
+template <>
+class TAsyncDispatchProcessorT<protocol::TProtocol> :
+  public TAsyncDispatchProcessor {};
+
+}}} // apache::thrift::async
+
+#endif // _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_
