From: Mark Slee Date: Mon, 5 Mar 2007 22:55:59 +0000 (+0000) Subject: Get rid of all the using namespace and using boost:: declarations in Thrift header... X-Git-Tag: 0.2.0~1425 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=5ea15f9e3206a4bb903f77d149b9cb8c1c2a392e;p=common%2Fthrift.git Get rid of all the using namespace and using boost:: declarations in Thrift header files Summary: To remove upstream dependencies. Still keeping some specific using directives around. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665047 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/src/TProcessor.h b/lib/cpp/src/TProcessor.h index efda0341..affbe812 100644 --- a/lib/cpp/src/TProcessor.h +++ b/lib/cpp/src/TProcessor.h @@ -13,10 +13,6 @@ namespace facebook { namespace thrift { -using namespace boost; - -using namespace facebook::thrift::protocol; - /** * A processor is a generic object that acts upon two streams of data, one * an input and the other an output. The definition of this object is loose, @@ -29,10 +25,10 @@ class TProcessor { public: virtual ~TProcessor() {} - virtual bool process(shared_ptr in, - shared_ptr out) = 0; + virtual bool process(boost::shared_ptr in, + boost::shared_ptr out) = 0; - bool process(shared_ptr io) { + bool process(boost::shared_ptr io) { return process(io, io); } diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h index 749ae454..d58ce6cc 100644 --- a/lib/cpp/src/Thrift.h +++ b/lib/cpp/src/Thrift.h @@ -98,8 +98,8 @@ public: } } - uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot); - uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const; + uint32_t TApplicationException::read(protocol::TProtocol* iprot); + uint32_t TApplicationException::write(protocol::TProtocol* oprot) const; protected: /** diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.h b/lib/cpp/src/concurrency/PosixThreadFactory.h index 4e50dffd..ede7d79b 100644 --- a/lib/cpp/src/concurrency/PosixThreadFactory.h +++ b/lib/cpp/src/concurrency/PosixThreadFactory.h @@ -13,8 +13,6 @@ namespace facebook { namespace thrift { namespace concurrency { -using namespace boost; - /** * A thread factory to create posix threads * @@ -57,7 +55,7 @@ class PosixThreadFactory : public ThreadFactory { PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=false); // From ThreadFactory; - shared_ptr newThread(shared_ptr runnable) const; + boost::shared_ptr newThread(boost::shared_ptr runnable) const; /** * Sets stack size for created threads @@ -85,7 +83,7 @@ class PosixThreadFactory : public ThreadFactory { private: class Impl; - shared_ptr impl_; + boost::shared_ptr impl_; }; }}} // facebook::thrift::concurrency diff --git a/lib/cpp/src/concurrency/Thread.h b/lib/cpp/src/concurrency/Thread.h index 1b07fd50..96ca6681 100644 --- a/lib/cpp/src/concurrency/Thread.h +++ b/lib/cpp/src/concurrency/Thread.h @@ -12,8 +12,6 @@ namespace facebook { namespace thrift { namespace concurrency { -using namespace boost; - class Thread; /** @@ -30,18 +28,18 @@ class Runnable { /** * Gets the thread object that is hosting this runnable object - can return - * an empty shared pointer if no references remain on thet thread object + * an empty boost::shared pointer if no references remain on thet thread object */ - virtual shared_ptr thread() { return thread_.lock(); } + virtual boost::shared_ptr thread() { return thread_.lock(); } /** * Sets the thread that is executing this object. This is only meant for * use by concrete implementations of Thread. */ - virtual void thread(shared_ptr value) { thread_ = value; } + virtual void thread(boost::shared_ptr value) { thread_ = value; } private: - weak_ptr thread_; + boost::weak_ptr thread_; }; /** @@ -74,13 +72,13 @@ class Thread { /** * Gets the runnable object this thread is hosting */ - virtual shared_ptr runnable() const { return _runnable; } + virtual boost::shared_ptr runnable() const { return _runnable; } protected: - virtual void runnable(shared_ptr value) { _runnable = value; } + virtual void runnable(boost::shared_ptr value) { _runnable = value; } private: - shared_ptr _runnable; + boost::shared_ptr _runnable; }; /** @@ -91,7 +89,7 @@ class ThreadFactory { public: virtual ~ThreadFactory() {} - virtual shared_ptr newThread(shared_ptr runnable) const = 0; + virtual boost::shared_ptr newThread(boost::shared_ptr runnable) const = 0; }; }}} // facebook::thrift::concurrency diff --git a/lib/cpp/src/concurrency/ThreadManager.h b/lib/cpp/src/concurrency/ThreadManager.h index cc13665a..f0c745fa 100644 --- a/lib/cpp/src/concurrency/ThreadManager.h +++ b/lib/cpp/src/concurrency/ThreadManager.h @@ -13,8 +13,6 @@ namespace facebook { namespace thrift { namespace concurrency { -using namespace boost; - /** * Thread Pool Manager and related classes * @@ -81,9 +79,9 @@ class ThreadManager { virtual const STATE state() const = 0; - virtual shared_ptr threadFactory() const = 0; + virtual boost::shared_ptr threadFactory() const = 0; - virtual void threadFactory(shared_ptr value) = 0; + virtual void threadFactory(boost::shared_ptr value) = 0; virtual void addWorker(size_t value=1) = 0; @@ -114,19 +112,19 @@ class ThreadManager { * * @param value The task to run */ - virtual void add(shared_ptrvalue) = 0; + virtual void add(boost::shared_ptrvalue) = 0; /** * Removes a pending task */ - virtual void remove(shared_ptr task) = 0; + virtual void remove(boost::shared_ptr task) = 0; - static shared_ptr newThreadManager(); + static boost::shared_ptr newThreadManager(); /** * Creates a simple thread manager the uses count number of worker threads */ - static shared_ptr newSimpleThreadManager(size_t count=4); + static boost::shared_ptr newSimpleThreadManager(size_t count=4); class Task; diff --git a/lib/cpp/src/concurrency/TimerManager.cpp b/lib/cpp/src/concurrency/TimerManager.cpp index 09f7a9c5..050885d4 100644 --- a/lib/cpp/src/concurrency/TimerManager.cpp +++ b/lib/cpp/src/concurrency/TimerManager.cpp @@ -14,6 +14,8 @@ namespace facebook { namespace thrift { namespace concurrency { +using boost::shared_ptr; + typedef std::multimap >::iterator task_iterator; typedef std::pair task_range; diff --git a/lib/cpp/src/concurrency/TimerManager.h b/lib/cpp/src/concurrency/TimerManager.h index 4e83c9ec..a150e8a1 100644 --- a/lib/cpp/src/concurrency/TimerManager.h +++ b/lib/cpp/src/concurrency/TimerManager.h @@ -17,8 +17,6 @@ namespace facebook { namespace thrift { namespace concurrency { -using namespace boost; - /** * Timer Manager * @@ -35,9 +33,9 @@ class TimerManager { virtual ~TimerManager(); - virtual shared_ptr threadFactory() const; + virtual boost::shared_ptr threadFactory() const; - virtual void threadFactory(shared_ptr value); + virtual void threadFactory(boost::shared_ptr value); /** * Starts the timer manager service @@ -59,7 +57,7 @@ class TimerManager { * @param task The task to execute * @param timeout Time in milliseconds to delay before executing task */ - virtual void add(shared_ptr task, long long timeout); + virtual void add(boost::shared_ptr task, long long timeout); /** * Adds a task to be executed at some time in the future by a worker thread. @@ -67,7 +65,7 @@ class TimerManager { * @param task The task to execute * @param timeout Absolute time in the future to execute task. */ - virtual void add(shared_ptr task, const struct timespec& timeout); + virtual void add(boost::shared_ptr task, const struct timespec& timeout); /** * Removes a pending task @@ -79,7 +77,7 @@ class TimerManager { * @throws UncancellableTaskException Specified task is already being * executed or has completed execution. */ - virtual void remove(shared_ptr task); + virtual void remove(boost::shared_ptr task); enum STATE { UNINITIALIZED, @@ -92,17 +90,17 @@ class TimerManager { virtual const STATE state() const; private: - shared_ptr threadFactory_; + boost::shared_ptr threadFactory_; class Task; friend class Task; - std::multimap > taskMap_; + std::multimap > taskMap_; size_t taskCount_; Monitor monitor_; STATE state_; class Dispatcher; friend class Dispatcher; - shared_ptr dispatcher_; - shared_ptr dispatcherThread_; + boost::shared_ptr dispatcher_; + boost::shared_ptr dispatcherThread_; }; }}} // facebook::thrift::concurrency diff --git a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h index 3f588590..90d0e4f7 100644 --- a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +++ b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h @@ -15,6 +15,7 @@ namespace facebook { namespace thrift { namespace concurrency { namespace test { +using boost::shared_ptr; using namespace facebook::thrift::concurrency; /** diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h index b9bf0e94..6a85491a 100644 --- a/lib/cpp/src/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/protocol/TBinaryProtocol.h @@ -13,8 +13,6 @@ namespace facebook { namespace thrift { namespace protocol { -using namespace boost; - /** * The default binary protocol for thrift. Writes all data in a very basic * binary format, essentially just spitting out the raw bytes. @@ -23,14 +21,14 @@ using namespace boost; */ class TBinaryProtocol : public TProtocol { public: - TBinaryProtocol(shared_ptr trans) : + TBinaryProtocol(boost::shared_ptr trans) : TProtocol(trans), string_limit_(0), container_limit_(0), string_buf_(NULL), string_buf_size_(0) {} - TBinaryProtocol(shared_ptr trans, + TBinaryProtocol(boost::shared_ptr trans, int32_t string_limit, int32_t container_limit) : TProtocol(trans), diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h index 8b2e6bd7..735268e1 100644 --- a/lib/cpp/src/protocol/TProtocol.h +++ b/lib/cpp/src/protocol/TProtocol.h @@ -19,9 +19,7 @@ namespace facebook { namespace thrift { namespace protocol { -using namespace boost; - -using namespace facebook::thrift::transport; +using facebook::thrift::transport::TTransport; #if __BYTE_ORDER == __BIG_ENDIAN #define ntohll(n) (n) @@ -290,26 +288,26 @@ class TProtocol { } } - inline shared_ptr getTransport() { + inline boost::shared_ptr getTransport() { return ptrans_; } // TODO: remove these two calls, they are for backwards // compatibility - inline shared_ptr getInputTransport() { + inline boost::shared_ptr getInputTransport() { return ptrans_; } - inline shared_ptr getOutputTransport() { + inline boost::shared_ptr getOutputTransport() { return ptrans_; } protected: - TProtocol(shared_ptr ptrans): + TProtocol(boost::shared_ptr ptrans): ptrans_(ptrans) { trans_ = ptrans.get(); } - shared_ptr ptrans_; + boost::shared_ptr ptrans_; TTransport* trans_; private: diff --git a/lib/cpp/src/server/TNonblockingServer.cpp b/lib/cpp/src/server/TNonblockingServer.cpp index e73da120..2b910a58 100644 --- a/lib/cpp/src/server/TNonblockingServer.cpp +++ b/lib/cpp/src/server/TNonblockingServer.cpp @@ -15,7 +15,10 @@ namespace facebook { namespace thrift { namespace server { - void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) { +using namespace facebook::thrift::protocol; +using namespace facebook::thrift::transport; + +void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) { socket_ = socket; server_ = s; appState_ = APP_INIT; diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h index abfd5fae..e4f83468 100644 --- a/lib/cpp/src/server/TNonblockingServer.h +++ b/lib/cpp/src/server/TNonblockingServer.h @@ -15,7 +15,8 @@ namespace facebook { namespace thrift { namespace server { -using boost::shared_ptr; +using facebook::thrift::transport::TMemoryBuffer; +using facebook::thrift::protocol::TProtocol; // Forward declaration of class class TConnection; @@ -56,31 +57,31 @@ class TNonblockingServer : public TServer { void handleEvent(int fd, short which); public: - TNonblockingServer(shared_ptr processor, + TNonblockingServer(boost::shared_ptr processor, int port) : TServer(processor), serverSocket_(0), port_(port), frameResponses_(true) {} - TNonblockingServer(shared_ptr processor, - shared_ptr protocolFactory, + TNonblockingServer(boost::shared_ptr processor, + boost::shared_ptr protocolFactory, int port) : TServer(processor), serverSocket_(0), port_(port), frameResponses_(true) { - setInputTransportFactory(shared_ptr(new TTransportFactory())); - setOutputTransportFactory(shared_ptr(new TTransportFactory())); + setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); + setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); setInputProtocolFactory(protocolFactory); setOutputProtocolFactory(protocolFactory); } - TNonblockingServer(shared_ptr processor, - shared_ptr inputTransportFactory, - shared_ptr outputTransportFactory, - shared_ptr inputProtocolFactory, - shared_ptr outputProtocolFactory, + TNonblockingServer(boost::shared_ptr processor, + boost::shared_ptr inputTransportFactory, + boost::shared_ptr outputTransportFactory, + boost::shared_ptr inputProtocolFactory, + boost::shared_ptr outputProtocolFactory, int port) : TServer(processor), serverSocket_(0), @@ -186,20 +187,20 @@ class TConnection { int32_t frameSize_; // Transport to read from - shared_ptr inputTransport_; + boost::shared_ptr inputTransport_; // Transport that processor writes to - shared_ptr outputTransport_; + boost::shared_ptr outputTransport_; // extra transport generated by transport factory (e.g. BufferedRouterTransport) - shared_ptr factoryInputTransport_; - shared_ptr factoryOutputTransport_; + boost::shared_ptr factoryInputTransport_; + boost::shared_ptr factoryOutputTransport_; // Protocol decoder - shared_ptr inputProtocol_; + boost::shared_ptr inputProtocol_; // Protocol encoder - shared_ptr outputProtocol_; + boost::shared_ptr outputProtocol_; // Go into read mode void setRead() { @@ -233,8 +234,8 @@ class TConnection { // Allocate input and output tranpsorts // these only need to be allocated once per TConnection (they don't need to be // reallocated on init() call) - inputTransport_ = shared_ptr(new TMemoryBuffer(readBuffer_, readBufferSize_)); - outputTransport_ = shared_ptr(new TMemoryBuffer()); + inputTransport_ = boost::shared_ptr(new TMemoryBuffer(readBuffer_, readBufferSize_)); + outputTransport_ = boost::shared_ptr(new TMemoryBuffer()); init(socket, eventFlags, s); } diff --git a/lib/cpp/src/server/TServer.h b/lib/cpp/src/server/TServer.h index 2936e421..5f132553 100644 --- a/lib/cpp/src/server/TServer.h +++ b/lib/cpp/src/server/TServer.h @@ -16,9 +16,12 @@ namespace facebook { namespace thrift { namespace server { -using namespace facebook::thrift; -using namespace facebook::thrift::transport; -using namespace boost; +using facebook::thrift::TProcessor; +using facebook::thrift::protocol::TBinaryProtocolFactory; +using facebook::thrift::protocol::TProtocolFactory; +using facebook::thrift::transport::TServerTransport; +using facebook::thrift::transport::TTransport; +using facebook::thrift::transport::TTransportFactory; /** * Thrift server. @@ -38,53 +41,53 @@ public: serve(); } - shared_ptr getProcessor() { + boost::shared_ptr getProcessor() { return processor_; } - shared_ptr getServerTransport() { + boost::shared_ptr getServerTransport() { return serverTransport_; } - shared_ptr getInputTransportFactory() { + boost::shared_ptr getInputTransportFactory() { return inputTransportFactory_; } - shared_ptr getOutputTransportFactory() { + boost::shared_ptr getOutputTransportFactory() { return outputTransportFactory_; } - shared_ptr getInputProtocolFactory() { + boost::shared_ptr getInputProtocolFactory() { return inputProtocolFactory_; } - shared_ptr getOutputProtocolFactory() { + boost::shared_ptr getOutputProtocolFactory() { return outputProtocolFactory_; } protected: - TServer(shared_ptr processor): + TServer(boost::shared_ptr processor): processor_(processor) { - setInputTransportFactory(shared_ptr(new TTransportFactory())); - setOutputTransportFactory(shared_ptr(new TTransportFactory())); - setInputProtocolFactory(shared_ptr(new TBinaryProtocolFactory())); - setOutputProtocolFactory(shared_ptr(new TBinaryProtocolFactory())); + setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); + setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); + setInputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); + setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - TServer(shared_ptr processor, - shared_ptr serverTransport): + TServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport): processor_(processor), serverTransport_(serverTransport) { - setInputTransportFactory(shared_ptr(new TTransportFactory())); - setOutputTransportFactory(shared_ptr(new TTransportFactory())); - setInputProtocolFactory(shared_ptr(new TBinaryProtocolFactory())); - setOutputProtocolFactory(shared_ptr(new TBinaryProtocolFactory())); + setInputTransportFactory(boost::shared_ptr(new TTransportFactory())); + setOutputTransportFactory(boost::shared_ptr(new TTransportFactory())); + setInputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); + setOutputProtocolFactory(boost::shared_ptr(new TBinaryProtocolFactory())); } - TServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr transportFactory, - shared_ptr protocolFactory): + TServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr transportFactory, + boost::shared_ptr protocolFactory): processor_(processor), serverTransport_(serverTransport), inputTransportFactory_(transportFactory), @@ -92,12 +95,12 @@ protected: inputProtocolFactory_(protocolFactory), outputProtocolFactory_(protocolFactory) {} - TServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr inputTransportFactory, - shared_ptr outputTransportFactory, - shared_ptr inputProtocolFactory, - shared_ptr outputProtocolFactory): + TServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr inputTransportFactory, + boost::shared_ptr outputTransportFactory, + boost::shared_ptr inputProtocolFactory, + boost::shared_ptr outputProtocolFactory): processor_(processor), serverTransport_(serverTransport), inputTransportFactory_(inputTransportFactory), @@ -107,28 +110,28 @@ protected: // Class variables - shared_ptr processor_; - shared_ptr serverTransport_; + boost::shared_ptr processor_; + boost::shared_ptr serverTransport_; - shared_ptr inputTransportFactory_; - shared_ptr outputTransportFactory_; + boost::shared_ptr inputTransportFactory_; + boost::shared_ptr outputTransportFactory_; - shared_ptr inputProtocolFactory_; - shared_ptr outputProtocolFactory_; + boost::shared_ptr inputProtocolFactory_; + boost::shared_ptr outputProtocolFactory_; - void setInputTransportFactory(shared_ptr inputTransportFactory) { + void setInputTransportFactory(boost::shared_ptr inputTransportFactory) { inputTransportFactory_ = inputTransportFactory; } - void setOutputTransportFactory(shared_ptr outputTransportFactory) { + void setOutputTransportFactory(boost::shared_ptr outputTransportFactory) { outputTransportFactory_ = outputTransportFactory; } - void setInputProtocolFactory(shared_ptr inputProtocolFactory) { + void setInputProtocolFactory(boost::shared_ptr inputProtocolFactory) { inputProtocolFactory_ = inputProtocolFactory; } - void setOutputProtocolFactory(shared_ptr outputProtocolFactory) { + void setOutputProtocolFactory(boost::shared_ptr outputProtocolFactory) { outputProtocolFactory_ = outputProtocolFactory; } diff --git a/lib/cpp/src/server/TSimpleServer.cpp b/lib/cpp/src/server/TSimpleServer.cpp index 40d7ed96..d5d3797b 100644 --- a/lib/cpp/src/server/TSimpleServer.cpp +++ b/lib/cpp/src/server/TSimpleServer.cpp @@ -8,10 +8,15 @@ #include "transport/TTransportException.h" #include #include -using namespace std; namespace facebook { namespace thrift { namespace server { +using namespace std; +using namespace facebook::thrift; +using namespace facebook::thrift::protocol; +using namespace facebook::thrift::transport; +using boost::shared_ptr; + /** * A simple single-threaded application server. Perfect for unit tests! * diff --git a/lib/cpp/src/server/TSimpleServer.h b/lib/cpp/src/server/TSimpleServer.h index 0bb03650..b02f1060 100644 --- a/lib/cpp/src/server/TSimpleServer.h +++ b/lib/cpp/src/server/TSimpleServer.h @@ -22,19 +22,19 @@ namespace facebook { namespace thrift { namespace server { */ class TSimpleServer : public TServer { public: - TSimpleServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr transportFactory, - shared_ptr protocolFactory) : + TSimpleServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr transportFactory, + boost::shared_ptr protocolFactory) : TServer(processor, serverTransport, transportFactory, protocolFactory), stop_(false) {} - TSimpleServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr inputTransportFactory, - shared_ptr outputTransportFactory, - shared_ptr inputProtocolFactory, - shared_ptr outputProtocolFactory): + TSimpleServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr inputTransportFactory, + boost::shared_ptr outputTransportFactory, + boost::shared_ptr inputProtocolFactory, + boost::shared_ptr outputProtocolFactory): TServer(processor, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory), diff --git a/lib/cpp/src/server/TThreadPoolServer.cpp b/lib/cpp/src/server/TThreadPoolServer.cpp index 2542de9d..c8a8693f 100644 --- a/lib/cpp/src/server/TThreadPoolServer.cpp +++ b/lib/cpp/src/server/TThreadPoolServer.cpp @@ -13,9 +13,11 @@ namespace facebook { namespace thrift { namespace server { +using boost::shared_ptr; using namespace std; using namespace facebook::thrift; using namespace facebook::thrift::concurrency; +using namespace facebook::thrift::protocol;; using namespace facebook::thrift::transport; class TThreadPoolServer::Task: public Runnable { diff --git a/lib/cpp/src/server/TThreadPoolServer.h b/lib/cpp/src/server/TThreadPoolServer.h index bdb0e47c..fd745015 100644 --- a/lib/cpp/src/server/TThreadPoolServer.h +++ b/lib/cpp/src/server/TThreadPoolServer.h @@ -15,27 +15,28 @@ namespace facebook { namespace thrift { namespace server { -using namespace facebook::thrift::concurrency; -using namespace facebook::thrift::transport; -using namespace boost; +using facebook::thrift::concurrency::ThreadManager; +using facebook::thrift::protocol::TProtocolFactory; +using facebook::thrift::transport::TServerTransport; +using facebook::thrift::transport::TTransportFactory; class TThreadPoolServer : public TServer { public: class Task; - TThreadPoolServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr transportFactory, - shared_ptr protocolFactory, - shared_ptr threadManager); - - TThreadPoolServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr inputTransportFactory, - shared_ptr outputTransportFactory, - shared_ptr inputProtocolFactory, - shared_ptr outputProtocolFactory, - shared_ptr threadManager); + TThreadPoolServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr transportFactory, + boost::shared_ptr protocolFactory, + boost::shared_ptr threadManager); + + TThreadPoolServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr inputTransportFactory, + boost::shared_ptr outputTransportFactory, + boost::shared_ptr inputProtocolFactory, + boost::shared_ptr outputProtocolFactory, + boost::shared_ptr threadManager); virtual ~TThreadPoolServer(); @@ -48,7 +49,7 @@ class TThreadPoolServer : public TServer { protected: - shared_ptr threadManager_; + boost::shared_ptr threadManager_; volatile bool stop_; diff --git a/lib/cpp/src/server/TThreadedServer.cpp b/lib/cpp/src/server/TThreadedServer.cpp index 85c72dc1..079e0464 100644 --- a/lib/cpp/src/server/TThreadedServer.cpp +++ b/lib/cpp/src/server/TThreadedServer.cpp @@ -15,8 +15,10 @@ namespace facebook { namespace thrift { namespace server { +using boost::shared_ptr; using namespace std; using namespace facebook::thrift; +using namespace facebook::thrift::protocol; using namespace facebook::thrift::transport; using namespace facebook::thrift::concurrency; diff --git a/lib/cpp/src/server/TThreadedServer.h b/lib/cpp/src/server/TThreadedServer.h index 453eda54..c6306b26 100644 --- a/lib/cpp/src/server/TThreadedServer.h +++ b/lib/cpp/src/server/TThreadedServer.h @@ -15,26 +15,27 @@ namespace facebook { namespace thrift { namespace server { -using namespace facebook::thrift::transport; -using namespace facebook::thrift::concurrency; -using namespace boost; +using facebook::thrift::TProcessor; +using facebook::thrift::transport::TServerTransport; +using facebook::thrift::transport::TTransportFactory; +using facebook::thrift::concurrency::ThreadFactory; class TThreadedServer : public TServer { public: class Task; - TThreadedServer(shared_ptr processor, - shared_ptr serverTransport, - shared_ptr transportFactory, - shared_ptr protocolFactory); + TThreadedServer(boost::shared_ptr processor, + boost::shared_ptr serverTransport, + boost::shared_ptr transportFactory, + boost::shared_ptr protocolFactory); virtual ~TThreadedServer(); virtual void serve(); protected: - shared_ptr threadFactory_; + boost::shared_ptr threadFactory_; }; diff --git a/lib/cpp/src/transport/TFileTransport.cpp b/lib/cpp/src/transport/TFileTransport.cpp index 86c7df2d..56009b7e 100644 --- a/lib/cpp/src/transport/TFileTransport.cpp +++ b/lib/cpp/src/transport/TFileTransport.cpp @@ -8,16 +8,19 @@ #include "TTransportUtils.h" #include - #include +#include #include #include #include #include #include +namespace facebook { namespace thrift { namespace transport { + +using boost::shared_ptr; using namespace std; +using namespace facebook::thrift::protocol; -namespace facebook { namespace thrift { namespace transport { TFileTransport::TFileTransport(string path) : readState_() diff --git a/lib/cpp/src/transport/TFileTransport.h b/lib/cpp/src/transport/TFileTransport.h index 635c883d..235a2fef 100644 --- a/lib/cpp/src/transport/TFileTransport.h +++ b/lib/cpp/src/transport/TFileTransport.h @@ -18,8 +18,8 @@ namespace facebook { namespace thrift { namespace transport { -using namespace boost; -using std::string; +using facebook::thrift::TProcessor; +using facebook::thrift::protocol::TProtocolFactory; // Data pertaining to a single event typedef struct eventInfo { @@ -129,7 +129,7 @@ class TFileTransportBuffer { */ class TFileTransport : public TTransport { public: - TFileTransport(string path); + TFileTransport(std::string path); ~TFileTransport(); // TODO: what is the correct behaviour for this? @@ -154,7 +154,7 @@ class TFileTransport : public TTransport { uint32_t getCurChunk(); // for changing the output file - void resetOutputFile(int fd, string filename, long long offset); + void resetOutputFile(int fd, std::string filename, long long offset); // Setter/Getter functions for user-controllable options void setReadBuffSize(uint32_t readBuffSize) { @@ -324,7 +324,7 @@ class TFileTransport : public TTransport { pthread_mutex_t mutex_; // File information - string filename_; + std::string filename_; int fd_; // Whether the writer thread and buffers have been initialized @@ -339,10 +339,10 @@ class TFileTransport : public TTransport { }; // Exception thrown when EOF is hit -class TEOFException : public facebook::thrift::TTransportException { + class TEOFException : TTransportException { public: TEOFException(): - facebook::thrift::TTransportException(TTransportException::END_OF_FILE) {}; + TTransportException(TTransportException::END_OF_FILE) {}; }; @@ -356,14 +356,14 @@ class TFileProcessor { * @param protocolFactory protocol factory * @param inputTransport file transport */ - TFileProcessor(shared_ptr processor, - shared_ptr protocolFactory, - shared_ptr inputTransport); + TFileProcessor(boost::shared_ptr processor, + boost::shared_ptr protocolFactory, + boost::shared_ptr inputTransport); - TFileProcessor(shared_ptr processor, - shared_ptr inputProtocolFactory, - shared_ptr outputProtocolFactory, - shared_ptr inputTransport); + TFileProcessor(boost::shared_ptr processor, + boost::shared_ptr inputProtocolFactory, + boost::shared_ptr outputProtocolFactory, + boost::shared_ptr inputTransport); /** * Constructor @@ -373,10 +373,10 @@ class TFileProcessor { * @param inputTransport input file transport * @param output output transport */ - TFileProcessor(shared_ptr processor, - shared_ptr protocolFactory, - shared_ptr inputTransport, - shared_ptr outputTransport); + TFileProcessor(boost::shared_ptr processor, + boost::shared_ptr protocolFactory, + boost::shared_ptr inputTransport, + boost::shared_ptr outputTransport); /** * processes events from the file @@ -393,11 +393,11 @@ class TFileProcessor { void processChunk(); private: - shared_ptr processor_; - shared_ptr inputProtocolFactory_; - shared_ptr outputProtocolFactory_; - shared_ptr inputTransport_; - shared_ptr outputTransport_; + boost::shared_ptr processor_; + boost::shared_ptr inputProtocolFactory_; + boost::shared_ptr outputProtocolFactory_; + boost::shared_ptr inputTransport_; + boost::shared_ptr outputTransport_; }; diff --git a/lib/cpp/src/transport/TServerSocket.h b/lib/cpp/src/transport/TServerSocket.h index b482e02f..969c00bd 100644 --- a/lib/cpp/src/transport/TServerSocket.h +++ b/lib/cpp/src/transport/TServerSocket.h @@ -38,7 +38,7 @@ class TServerSocket : public TServerTransport { } protected: - shared_ptr acceptImpl(); + boost::shared_ptr acceptImpl(); private: int port_; diff --git a/lib/cpp/src/transport/TServerTransport.h b/lib/cpp/src/transport/TServerTransport.h index bb477560..9512372e 100644 --- a/lib/cpp/src/transport/TServerTransport.h +++ b/lib/cpp/src/transport/TServerTransport.h @@ -13,8 +13,6 @@ namespace facebook { namespace thrift { namespace transport { -using namespace boost; - /** * Server transport framework. A server needs to have some facility for * creating base transports to read/write from. @@ -43,8 +41,8 @@ class TServerTransport { * @return A new TTransport object * @throws TTransportException if there is an error */ - shared_ptr accept() { - shared_ptr result = acceptImpl(); + boost::shared_ptr accept() { + boost::shared_ptr result = acceptImpl(); if (result == NULL) { throw TTransportException("accept() may not return NULL"); } @@ -73,7 +71,7 @@ class TServerTransport { * @return A newly allocated TTransport object * @throw TTransportException If an error occurs */ - virtual shared_ptr acceptImpl() = 0; + virtual boost::shared_ptr acceptImpl() = 0; }; diff --git a/lib/rb/COPYING b/lib/rb/COPYING new file mode 100644 index 00000000..039f21e3 --- /dev/null +++ b/lib/rb/COPYING @@ -0,0 +1,24 @@ +Thrift Software License +Copyright (c) 2006- Facebook, Inc. + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/lib/rb/LICENSE b/lib/rb/LICENSE new file mode 100644 index 00000000..039f21e3 --- /dev/null +++ b/lib/rb/LICENSE @@ -0,0 +1,24 @@ +Thrift Software License +Copyright (c) 2006- Facebook, Inc. + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.