-- Thrift fixes
authorAditya Agarwal <aditya@apache.org>
Wed, 11 Oct 2006 02:42:49 +0000 (02:42 +0000)
committerAditya Agarwal <aditya@apache.org>
Wed, 11 Oct 2006 02:42:49 +0000 (02:42 +0000)
Summary:
-- Made read buffering work (the buffer wasn't actually being used)
-- TServer now extends TRunnable (useful for testing)
-- Adding TLogging (the DEBUG and ERROR macros that we all know and love)

Reviewed By: Slee

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664824 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/Thrift.h
lib/cpp/src/server/TServer.h
lib/cpp/src/transport/TBufferedTransport.cc
lib/cpp/src/transport/TBufferedTransport.h
lib/cpp/src/transport/TTransport.h

index c21b0a5..92143cc 100644 (file)
@@ -10,6 +10,8 @@
 #include <vector>
 #include <exception>
 
+#include "TLogging.h"
+
 namespace facebook { namespace thrift {
 
 class Exception : public std::exception {
index eb23b45..293aa28 100644 (file)
@@ -21,10 +21,13 @@ class TServerOptions;
  *
  * @author Mark Slee <mcslee@facebook.com>
  */
-class TServer {
+class TServer : public concurrency::Runnable {
 public:
   virtual ~TServer() {}
   virtual void serve() = 0;
+
+  // Allows running the server as a Runnable thread
+  virtual void run() { serve(); }
   
   shared_ptr<TProcessor> getProcessor() {
     return processor_;
index cab02df..9dfd63a 100644 (file)
@@ -15,6 +15,7 @@ uint32_t TBufferedTransport::read(uint8_t* buf, uint32_t len) {
       buf += rLen_-rPos_;
     }    
     // Get more from underlying transport up to buffer size
+    // TODO: should this be a readAll?
     rLen_ = transport_->read(rBuf_, rBufSize_);
     rPos_ = 0;
   }
index 0783ca4..9992777 100644 (file)
@@ -60,12 +60,8 @@ class TBufferedTransport : public TTransport {
     transport_->close();
   }
 
-  uint32_t readAll(uint8_t* buf, uint32_t len) {
-    return transport_->readAll(buf, len);
-  }
-  
   uint32_t read(uint8_t* buf, uint32_t len);
-
+  
   void write(const uint8_t* buf, uint32_t len);
 
   void flush();
index 1a20bd5..c5456d5 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _THRIFT_TRANSPORT_TTRANSPORT_H_
 #define _THRIFT_TRANSPORT_TTRANSPORT_H_ 1
 
+#include "Thrift.h"
 #include <transport/TTransportException.h>
 #include <string>
 
@@ -72,7 +73,7 @@ class TTransport {
       }
       have += get;
     }
-
+    
     return have;
   }