Update Thrift CPP libraries to work with new generated source, change underlying buffers to use uint8_t* instead of std::string
Summary: Major overhaul to the CPP libraries.
Reviewed By: aditya
Test Plan: Again, keep an eye out for the unit tests commit
Notes: Initial perf tests show that Thrift is not only more robust than Pillar, but its implementation is actually around 10-20% faster. We can do about 10 RPC function calls with small data payloads in under 2ms. THAT IS FAST. THAT IS THRIFTY.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664714 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/transport/TServerTransport.h b/lib/cpp/transport/TServerTransport.h
index 4d063fc..9d71539 100644
--- a/lib/cpp/transport/TServerTransport.h
+++ b/lib/cpp/transport/TServerTransport.h
@@ -1,7 +1,8 @@
#ifndef T_SERVER_TRANSPORT_H
#define T_SERVER_TRANSPORT_H
-#include "TTransport.h"
+#include "transport/TTransport.h"
+#include "transport/TTransportException.h"
/**
* Server transport framework. A server needs to have some facility for
@@ -13,12 +14,48 @@
public:
virtual ~TServerTransport() {}
- virtual bool listen() = 0;
- virtual TTransport* accept() = 0;
+ /**
+ * Starts the server transport listening for new connections. Prior to this
+ * call most transports will not return anything when accept is called.
+ *
+ * @throws TTransportException if we were unable to listen
+ */
+ virtual void listen() {}
+
+ /**
+ * Gets a new dynamically allocated transport object and passes it to the
+ * caller. Note that it is the explicit duty of the caller to free the
+ * allocated object. The returned TTransport object must always be in the
+ * opened state. NULL should never be returned, instead an Exception should
+ * always be thrown.
+ *
+ * @return A new TTransport object
+ * @throws TTransportException if there is an error
+ */
+ TTransport* accept() {
+ TTransport* result = acceptImpl();
+ if (result == NULL) {
+ throw TTransportException("accept() may not return NULL");
+ }
+ return result;
+ }
+
+ /**
+ * Closes this transport such that future calls to accept will do nothing.
+ */
virtual void close() = 0;
protected:
TServerTransport() {}
+
+ /**
+ * Subclasses should implement this function for accept.
+ *
+ * @return A newly allocated TTransport object
+ * @throw TTransportException If an error occurs
+ */
+ virtual TTransport* acceptImpl() = 0;
+
};
#endif