http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp index 6a0b47c..6bf043b 100644 --- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp @@ -31,15 +31,12 @@ #include <iostream> -#include <boost/weak_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; -using boost::weak_ptr; - /** * The POSIX thread class. * @@ -59,7 +56,7 @@ private: int policy_; int priority_; int stackSize_; - weak_ptr<PthreadThread> self_; + stdcxx::weak_ptr<PthreadThread> self_; bool detached_; public: @@ -67,7 +64,7 @@ public: int priority, int stackSize, bool detached, - shared_ptr<Runnable> runnable) + stdcxx::shared_ptr<Runnable> runnable) : #ifndef _WIN32 @@ -139,7 +136,7 @@ public: } // Create reference - shared_ptr<PthreadThread>* selfRef = new shared_ptr<PthreadThread>(); + stdcxx::shared_ptr<PthreadThread>* selfRef = new stdcxx::shared_ptr<PthreadThread>(); *selfRef = self_.lock(); state_ = starting; @@ -178,19 +175,19 @@ public: #endif // _WIN32 } - shared_ptr<Runnable> runnable() const { return Thread::runnable(); } + stdcxx::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } - void runnable(shared_ptr<Runnable> value) { Thread::runnable(value); } + void runnable(stdcxx::shared_ptr<Runnable> value) { Thread::runnable(value); } - void weakRef(shared_ptr<PthreadThread> self) { + void weakRef(stdcxx::shared_ptr<PthreadThread> self) { assert(self.get() == this); - self_ = weak_ptr<PthreadThread>(self); + self_ = stdcxx::weak_ptr<PthreadThread>(self); } }; void* PthreadThread::threadMain(void* arg) { - shared_ptr<PthreadThread> thread = *(shared_ptr<PthreadThread>*)arg; - delete reinterpret_cast<shared_ptr<PthreadThread>*>(arg); + stdcxx::shared_ptr<PthreadThread> thread = *(stdcxx::shared_ptr<PthreadThread>*)arg; + delete reinterpret_cast<stdcxx::shared_ptr<PthreadThread>*>(arg); if (thread == NULL) { return (void*)0; @@ -276,9 +273,9 @@ PosixThreadFactory::PosixThreadFactory(bool detached) stackSize_(1) { } -shared_ptr<Thread> PosixThreadFactory::newThread(shared_ptr<Runnable> runnable) const { - shared_ptr<PthreadThread> result - = shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_), +stdcxx::shared_ptr<Thread> PosixThreadFactory::newThread(stdcxx::shared_ptr<Runnable> runnable) const { + stdcxx::shared_ptr<PthreadThread> result + = stdcxx::shared_ptr<PthreadThread>(new PthreadThread(toPthreadPolicy(policy_), toPthreadPriority(policy_, priority_), stackSize_, isDetached(),
http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h index c1bbe5c..5e04d01 100644 --- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h +++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.h @@ -22,7 +22,7 @@ #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -63,9 +63,9 @@ public: /** * Posix thread (pthread) factory. All threads created by a factory are reference-counted - * via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and - * the Runnable tasks they host will be properly cleaned up once the last strong reference - * to both is given up. + * via stdcxx::shared_ptr. The factory guarantees that threads and the Runnable tasks + * they host will be properly cleaned up once the last strong reference to both is + * given up. * * Threads are created with the specified policy, priority, stack-size and detachable-mode * detached means the thread is free-running and will release all system resources the @@ -88,7 +88,7 @@ public: PosixThreadFactory(bool detached); // From ThreadFactory; - boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const; + stdcxx::shared_ptr<Thread> newThread(stdcxx::shared_ptr<Runnable> runnable) const; // From ThreadFactory; Thread::id_t getCurrentThreadId() const; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp index 4fca8da..4067f24 100644 --- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp +++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp @@ -23,11 +23,9 @@ #include <thrift/concurrency/StdThreadFactory.h> #include <thrift/concurrency/Exception.h> +#include <thrift/stdcxx.h> #include <cassert> - -#include <boost/enable_shared_from_this.hpp> -#include <boost/weak_ptr.hpp> #include <thread> namespace apache { @@ -43,11 +41,11 @@ namespace concurrency { * * @version $Id:$ */ -class StdThread : public Thread, public boost::enable_shared_from_this<StdThread> { +class StdThread : public Thread, public stdcxx::enable_shared_from_this<StdThread> { public: enum STATE { uninitialized, starting, started, stopping, stopped }; - static void threadMain(boost::shared_ptr<StdThread> thread); + static void threadMain(stdcxx::shared_ptr<StdThread> thread); private: std::unique_ptr<std::thread> thread_; @@ -55,7 +53,7 @@ private: bool detached_; public: - StdThread(bool detached, boost::shared_ptr<Runnable> runnable) + StdThread(bool detached, stdcxx::shared_ptr<Runnable> runnable) : state_(uninitialized), detached_(detached) { this->Thread::runnable(runnable); } @@ -75,7 +73,7 @@ public: return; } - boost::shared_ptr<StdThread> selfRef = shared_from_this(); + stdcxx::shared_ptr<StdThread> selfRef = shared_from_this(); state_ = starting; thread_ = std::unique_ptr<std::thread>(new std::thread(threadMain, selfRef)); @@ -92,12 +90,12 @@ public: Thread::id_t getId() { return thread_.get() ? thread_->get_id() : std::thread::id(); } - boost::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } + stdcxx::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } - void runnable(boost::shared_ptr<Runnable> value) { Thread::runnable(value); } + void runnable(stdcxx::shared_ptr<Runnable> value) { Thread::runnable(value); } }; -void StdThread::threadMain(boost::shared_ptr<StdThread> thread) { +void StdThread::threadMain(stdcxx::shared_ptr<StdThread> thread) { if (thread == NULL) { return; } @@ -119,8 +117,8 @@ void StdThread::threadMain(boost::shared_ptr<StdThread> thread) { StdThreadFactory::StdThreadFactory(bool detached) : ThreadFactory(detached) { } -boost::shared_ptr<Thread> StdThreadFactory::newThread(boost::shared_ptr<Runnable> runnable) const { - boost::shared_ptr<StdThread> result = boost::shared_ptr<StdThread>(new StdThread(isDetached(), runnable)); +stdcxx::shared_ptr<Thread> StdThreadFactory::newThread(stdcxx::shared_ptr<Runnable> runnable) const { + stdcxx::shared_ptr<StdThread> result = stdcxx::shared_ptr<StdThread>(new StdThread(isDetached(), runnable)); runnable->thread(result); return result; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/StdThreadFactory.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h index 88f00be..8e116b6 100644 --- a/lib/cpp/src/thrift/concurrency/StdThreadFactory.h +++ b/lib/cpp/src/thrift/concurrency/StdThreadFactory.h @@ -22,7 +22,7 @@ #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -38,8 +38,8 @@ class StdThreadFactory : public ThreadFactory { public: /** * Std thread factory. All threads created by a factory are reference-counted - * via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and - * the Runnable tasks they host will be properly cleaned up once the last strong reference + * via stdcxx::shared_ptr. The factory guarantees that threads and the Runnable tasks + * they host will be properly cleaned up once the last strong reference * to both is given up. * * By default threads are not joinable. @@ -48,7 +48,7 @@ public: StdThreadFactory(bool detached = true); // From ThreadFactory; - boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const; + stdcxx::shared_ptr<Thread> newThread(stdcxx::shared_ptr<Runnable> runnable) const; // From ThreadFactory; Thread::id_t getCurrentThreadId() const; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/Thread.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/Thread.h b/lib/cpp/src/thrift/concurrency/Thread.h index 2e15489..788623b 100644 --- a/lib/cpp/src/thrift/concurrency/Thread.h +++ b/lib/cpp/src/thrift/concurrency/Thread.h @@ -21,8 +21,7 @@ #define _THRIFT_CONCURRENCY_THREAD_H_ 1 #include <stdint.h> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/thrift-config.h> @@ -57,16 +56,16 @@ public: * Gets the thread object that is hosting this runnable object - can return * an empty boost::shared pointer if no references remain on that thread object */ - virtual boost::shared_ptr<Thread> thread() { return thread_.lock(); } + virtual stdcxx::shared_ptr<Thread> 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(boost::shared_ptr<Thread> value) { thread_ = value; } + virtual void thread(stdcxx::shared_ptr<Thread> value) { thread_ = value; } private: - boost::weak_ptr<Thread> thread_; + stdcxx::weak_ptr<Thread> thread_; }; /** @@ -122,13 +121,13 @@ public: /** * Gets the runnable object this thread is hosting */ - virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; } + virtual stdcxx::shared_ptr<Runnable> runnable() const { return _runnable; } protected: - virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; } + virtual void runnable(stdcxx::shared_ptr<Runnable> value) { _runnable = value; } private: - boost::shared_ptr<Runnable> _runnable; + stdcxx::shared_ptr<Runnable> _runnable; }; /** @@ -155,7 +154,7 @@ public: /** * Create a new thread. */ - virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0; + virtual stdcxx::shared_ptr<Thread> newThread(stdcxx::shared_ptr<Runnable> runnable) const = 0; /** * Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/ThreadManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp index 88cd59a..2e27b7f 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp @@ -24,7 +24,7 @@ #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Util.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <stdexcept> #include <deque> @@ -34,8 +34,8 @@ namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using stdcxx::shared_ptr; +using stdcxx::dynamic_pointer_cast; /** * ThreadManager class @@ -504,7 +504,7 @@ void ThreadManager::Impl::remove(shared_ptr<Runnable> task) { } } -boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { +stdcxx::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { Guard g(mutex_); if (state_ != ThreadManager::STARTED) { throw IllegalStateException( @@ -513,7 +513,7 @@ boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { } if (tasks_.empty()) { - return boost::shared_ptr<Runnable>(); + return stdcxx::shared_ptr<Runnable>(); } shared_ptr<ThreadManager::Task> task = tasks_.front(); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/ThreadManager.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.h b/lib/cpp/src/thrift/concurrency/ThreadManager.h index d8bf71b..b3b7542 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.h +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.h @@ -20,10 +20,9 @@ #ifndef _THRIFT_CONCURRENCY_THREADMANAGER_H_ #define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1 -#include <boost/shared_ptr.hpp> -#include <thrift/cxxfunctional.h> #include <sys/types.h> #include <thrift/concurrency/Thread.h> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -59,7 +58,7 @@ protected: ThreadManager() {} public: - typedef apache::thrift::stdcxx::function<void(boost::shared_ptr<Runnable>)> ExpireCallback; + typedef apache::thrift::stdcxx::function<void(stdcxx::shared_ptr<Runnable>)> ExpireCallback; virtual ~ThreadManager() {} @@ -88,14 +87,14 @@ public: /** * \returns the current thread factory */ - virtual boost::shared_ptr<ThreadFactory> threadFactory() const = 0; + virtual stdcxx::shared_ptr<ThreadFactory> threadFactory() const = 0; /** * Set the thread factory. * \throws InvalidArgumentException if the new thread factory has a different * detached disposition than the one replacing it */ - virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0; + virtual void threadFactory(stdcxx::shared_ptr<ThreadFactory> value) = 0; /** * Adds worker thread(s). @@ -162,21 +161,21 @@ public: * * @throws TooManyPendingTasksException Pending task count exceeds max pending task count */ - virtual void add(boost::shared_ptr<Runnable> task, + virtual void add(stdcxx::shared_ptr<Runnable> task, int64_t timeout = 0LL, int64_t expiration = 0LL) = 0; /** * Removes a pending task */ - virtual void remove(boost::shared_ptr<Runnable> task) = 0; + virtual void remove(stdcxx::shared_ptr<Runnable> task) = 0; /** * Remove the next pending task which would be run. * * @return the task removed. */ - virtual boost::shared_ptr<Runnable> removeNextPending() = 0; + virtual stdcxx::shared_ptr<Runnable> removeNextPending() = 0; /** * Remove tasks from front of task queue that have expired. @@ -191,14 +190,14 @@ public: */ virtual void setExpireCallback(ExpireCallback expireCallback) = 0; - static boost::shared_ptr<ThreadManager> newThreadManager(); + static stdcxx::shared_ptr<ThreadManager> newThreadManager(); /** * Creates a simple thread manager the uses count number of worker threads and has * a pendingTaskCountMax maximum pending tasks. The default, 0, specified no limit * on pending tasks */ - static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count = 4, + static stdcxx::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count = 4, size_t pendingTaskCountMax = 0); class Task; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/TimerManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp index f95fcda..b03ff42 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp +++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp @@ -29,7 +29,7 @@ namespace apache { namespace thrift { namespace concurrency { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * TimerManager class http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/concurrency/TimerManager.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.h b/lib/cpp/src/thrift/concurrency/TimerManager.h index 3946827..f664348 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.h +++ b/lib/cpp/src/thrift/concurrency/TimerManager.h @@ -24,7 +24,7 @@ #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Thread.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <map> #include <time.h> @@ -46,9 +46,9 @@ public: virtual ~TimerManager(); - virtual boost::shared_ptr<const ThreadFactory> threadFactory() const; + virtual stdcxx::shared_ptr<const ThreadFactory> threadFactory() const; - virtual void threadFactory(boost::shared_ptr<const ThreadFactory> value); + virtual void threadFactory(stdcxx::shared_ptr<const ThreadFactory> value); /** * Starts the timer manager service @@ -70,7 +70,7 @@ public: * @param task The task to execute * @param timeout Time in milliseconds to delay before executing task */ - virtual void add(boost::shared_ptr<Runnable> task, int64_t timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, int64_t timeout); /** * Adds a task to be executed at some time in the future by a worker thread. @@ -78,7 +78,7 @@ public: * @param task The task to execute * @param timeout Absolute time in the future to execute task. */ - virtual void add(boost::shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& timeout); /** * Adds a task to be executed at some time in the future by a worker thread. @@ -86,7 +86,7 @@ public: * @param task The task to execute * @param timeout Absolute time in the future to execute task. */ - virtual void add(boost::shared_ptr<Runnable> task, const struct timeval& timeout); + virtual void add(stdcxx::shared_ptr<Runnable> task, const struct timeval& timeout); /** * Removes a pending task @@ -98,25 +98,25 @@ public: * @throws UncancellableTaskException Specified task is already being * executed or has completed execution. */ - virtual void remove(boost::shared_ptr<Runnable> task); + virtual void remove(stdcxx::shared_ptr<Runnable> task); enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED }; virtual STATE state() const; private: - boost::shared_ptr<const ThreadFactory> threadFactory_; + stdcxx::shared_ptr<const ThreadFactory> threadFactory_; class Task; friend class Task; - std::multimap<int64_t, boost::shared_ptr<Task> > taskMap_; + std::multimap<int64_t, stdcxx::shared_ptr<Task> > taskMap_; size_t taskCount_; Monitor monitor_; STATE state_; class Dispatcher; friend class Dispatcher; - boost::shared_ptr<Dispatcher> dispatcher_; - boost::shared_ptr<Thread> dispatcherThread_; - typedef std::multimap<int64_t, boost::shared_ptr<TimerManager::Task> >::iterator task_iterator; + stdcxx::shared_ptr<Dispatcher> dispatcher_; + stdcxx::shared_ptr<Thread> dispatcherThread_; + typedef std::multimap<int64_t, stdcxx::shared_ptr<TimerManager::Task> >::iterator task_iterator; typedef std::pair<task_iterator, task_iterator> task_range; }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/cxxfunctional.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h deleted file mode 100644 index 32933a4..0000000 --- a/lib/cpp/src/thrift/cxxfunctional.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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_CXXFUNCTIONAL_H_ -#define _THRIFT_CXXFUNCTIONAL_H_ 1 - -// clang-format off - -/** - * Loads <functional> from the 'right' location, depending - * on compiler and whether or not it's using C++03 with TR1 - * or C++11. - */ - -/* - * MSVC 10 and 11 have the <functional> stuff at <functional>. - * In MSVC 10 all of the implementations live in std::tr1. - * In MSVC 11 all of the implementations live in std, with aliases - * in std::tr1 to point to the ones in std. - */ -#if defined(_WIN32) && !defined(__MINGW32__) - #define _THRIFT_USING_MICROSOFT_STDLIB 1 -#endif - -#ifdef __clang__ - /* Clang has two options, depending on standard library: - * - no -stdlib or -stdlib=libstdc++ set; uses GNU libstdc++. - * <tr1/functional> - * - -stdlib=libc++; uses LLVM libc++. - * <functional>, no 'std::tr1'. - * - * The compiler itself doesn't define anything differently - * depending on the value of -stdlib, but the library headers - * will set different preprocessor options. In order to check, - * though, we have to pull in some library header. - */ - #include <utility> - - /* With LLVM libc++, utility pulls in __config, which sets - _LIBCPP_VERSION. */ - #if defined(_LIBCPP_VERSION) - #define _THRIFT_USING_CLANG_LIBCXX 1 - - /* With GNU libstdc++, utility pulls in bits/c++config.h, - which sets __GLIBCXX__. */ - #elif defined(__GLIBCXX__) - #define _THRIFT_USING_GNU_LIBSTDCXX 1 - - /* No idea. */ - #else - #error Unable to detect which C++ standard library is in use. - #endif -#elif __GNUC__ - #define _THRIFT_USING_GNU_LIBSTDCXX 1 -#endif - -#if _THRIFT_USING_MICROSOFT_STDLIB - #include <functional> - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_CLANG_LIBCXX - #include <functional> - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::function; - using ::std::bind; - - namespace placeholders { - using ::std::placeholders::_1; - using ::std::placeholders::_2; - using ::std::placeholders::_3; - using ::std::placeholders::_4; - using ::std::placeholders::_5; - using ::std::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx - -#elif _THRIFT_USING_GNU_LIBSTDCXX - #ifdef USE_BOOST_THREAD - #include <boost/tr1/functional.hpp> - #else - #include <tr1/functional> - #endif - - namespace apache { namespace thrift { namespace stdcxx { - using ::std::tr1::function; - using ::std::tr1::bind; - - namespace placeholders { - using ::std::tr1::placeholders::_1; - using ::std::tr1::placeholders::_2; - using ::std::tr1::placeholders::_3; - using ::std::tr1::placeholders::_4; - using ::std::tr1::placeholders::_5; - using ::std::tr1::placeholders::_6; - } // apache::thrift::stdcxx::placeholders - }}} // apache::thrift::stdcxx -#endif - - // Alias for thrift c++ compatibility namespace - namespace tcxx = apache::thrift::stdcxx; - -#endif // #ifndef _THRIFT_CXXFUNCTIONAL_H_ http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/processor/PeekProcessor.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/lib/cpp/src/thrift/processor/PeekProcessor.cpp index 8c9a463..fa11a72 100644 --- a/lib/cpp/src/thrift/processor/PeekProcessor.cpp +++ b/lib/cpp/src/thrift/processor/PeekProcessor.cpp @@ -34,26 +34,26 @@ PeekProcessor::PeekProcessor() { PeekProcessor::~PeekProcessor() { } -void PeekProcessor::initialize(boost::shared_ptr<TProcessor> actualProcessor, - boost::shared_ptr<TProtocolFactory> protocolFactory, - boost::shared_ptr<TPipedTransportFactory> transportFactory) { +void PeekProcessor::initialize(stdcxx::shared_ptr<TProcessor> actualProcessor, + stdcxx::shared_ptr<TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<TPipedTransportFactory> transportFactory) { actualProcessor_ = actualProcessor; pipedProtocol_ = protocolFactory->getProtocol(targetTransport_); transportFactory_ = transportFactory; transportFactory_->initializeTargetTransport(targetTransport_); } -boost::shared_ptr<TTransport> PeekProcessor::getPipedTransport(boost::shared_ptr<TTransport> in) { +stdcxx::shared_ptr<TTransport> PeekProcessor::getPipedTransport(stdcxx::shared_ptr<TTransport> in) { return transportFactory_->getTransport(in); } -void PeekProcessor::setTargetTransport(boost::shared_ptr<TTransport> targetTransport) { +void PeekProcessor::setTargetTransport(stdcxx::shared_ptr<TTransport> targetTransport) { targetTransport_ = targetTransport; - if (boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>(targetTransport); - } else if (boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)) { - memoryBuffer_ = boost::dynamic_pointer_cast<TMemoryBuffer>( - boost::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport()); + if (stdcxx::dynamic_pointer_cast<TMemoryBuffer>(targetTransport_)) { + memoryBuffer_ = stdcxx::dynamic_pointer_cast<TMemoryBuffer>(targetTransport); + } else if (stdcxx::dynamic_pointer_cast<TPipedTransport>(targetTransport_)) { + memoryBuffer_ = stdcxx::dynamic_pointer_cast<TMemoryBuffer>( + stdcxx::dynamic_pointer_cast<TPipedTransport>(targetTransport_)->getTargetTransport()); } if (!memoryBuffer_) { @@ -62,8 +62,8 @@ void PeekProcessor::setTargetTransport(boost::shared_ptr<TTransport> targetTrans } } -bool PeekProcessor::process(boost::shared_ptr<TProtocol> in, - boost::shared_ptr<TProtocol> out, +bool PeekProcessor::process(stdcxx::shared_ptr<TProtocol> in, + stdcxx::shared_ptr<TProtocol> out, void* connectionContext) { std::string fname; @@ -120,7 +120,7 @@ void PeekProcessor::peekBuffer(uint8_t* buffer, uint32_t size) { (void)size; } -void PeekProcessor::peek(boost::shared_ptr<TProtocol> in, TType ftype, int16_t fid) { +void PeekProcessor::peek(stdcxx::shared_ptr<TProtocol> in, TType ftype, int16_t fid) { (void)fid; in->skip(ftype); } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/processor/PeekProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.h b/lib/cpp/src/thrift/processor/PeekProcessor.h index 21c5999..f5c10da 100644 --- a/lib/cpp/src/thrift/processor/PeekProcessor.h +++ b/lib/cpp/src/thrift/processor/PeekProcessor.h @@ -25,7 +25,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/transport/TBufferTransports.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -47,34 +47,34 @@ public: // transportFactory - this TPipedTransportFactory is used to wrap the source transport // via a call to getPipedTransport void initialize( - boost::shared_ptr<apache::thrift::TProcessor> actualProcessor, - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, - boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory); + stdcxx::shared_ptr<apache::thrift::TProcessor> actualProcessor, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, + stdcxx::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory); - boost::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport( - boost::shared_ptr<apache::thrift::transport::TTransport> in); + stdcxx::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport( + stdcxx::shared_ptr<apache::thrift::transport::TTransport> in); - void setTargetTransport(boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport); + void setTargetTransport(stdcxx::shared_ptr<apache::thrift::transport::TTransport> targetTransport); - virtual bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> in, - boost::shared_ptr<apache::thrift::protocol::TProtocol> out, + virtual bool process(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> in, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> out, void* connectionContext); // The following three functions can be overloaded by child classes to // achieve desired peeking behavior virtual void peekName(const std::string& fname); virtual void peekBuffer(uint8_t* buffer, uint32_t size); - virtual void peek(boost::shared_ptr<apache::thrift::protocol::TProtocol> in, + virtual void peek(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> in, apache::thrift::protocol::TType ftype, int16_t fid); virtual void peekEnd(); private: - boost::shared_ptr<apache::thrift::TProcessor> actualProcessor_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_; - boost::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_; - boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_; - boost::shared_ptr<apache::thrift::transport::TTransport> targetTransport_; + stdcxx::shared_ptr<apache::thrift::TProcessor> actualProcessor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_; + stdcxx::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_; + stdcxx::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_; + stdcxx::shared_ptr<apache::thrift::transport::TTransport> targetTransport_; }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/processor/StatsProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/processor/StatsProcessor.h b/lib/cpp/src/thrift/processor/StatsProcessor.h index e8ca067..8f6725f 100644 --- a/lib/cpp/src/thrift/processor/StatsProcessor.h +++ b/lib/cpp/src/thrift/processor/StatsProcessor.h @@ -20,7 +20,7 @@ #ifndef STATSPROCESSOR_H #define STATSPROCESSOR_H -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TTransport.h> #include <thrift/protocol/TProtocol.h> #include <TProcessor.h> @@ -38,8 +38,8 @@ public: StatsProcessor(bool print, bool frequency) : print_(print), frequency_(frequency) {} virtual ~StatsProcessor(){}; - virtual bool process(boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot, - boost::shared_ptr<apache::thrift::protocol::TProtocol> poprot, + virtual bool process(stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> piprot, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> poprot, void* serverContext) { piprot_ = piprot; @@ -229,7 +229,7 @@ protected: } } - boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> piprot_; std::map<std::string, int64_t> frequency_map_; bool print_; http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h index 0ef7261..13b09bb 100644 --- a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h +++ b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h @@ -27,7 +27,7 @@ namespace apache { namespace thrift { -using boost::shared_ptr; +using stdcxx::shared_ptr; namespace protocol { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TBinaryProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h index 87c53f7..f28d278 100644 --- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h @@ -23,7 +23,7 @@ #include <thrift/protocol/TProtocol.h> #include <thrift/protocol/TVirtualProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -41,7 +41,7 @@ public: static const int32_t VERSION_1 = ((int32_t)0x80010000); // VERSION_2 (0x80020000) was taken by TDenseProtocol (which has since been removed) - TBinaryProtocolT(boost::shared_ptr<Transport_> trans) + TBinaryProtocolT(stdcxx::shared_ptr<Transport_> trans) : TVirtualProtocol<TBinaryProtocolT<Transport_, ByteOrder_> >(trans), trans_(trans.get()), string_limit_(0), @@ -49,7 +49,7 @@ public: strict_read_(false), strict_write_(true) {} - TBinaryProtocolT(boost::shared_ptr<Transport_> trans, + TBinaryProtocolT(stdcxx::shared_ptr<Transport_> trans, int32_t string_limit, int32_t container_limit, bool strict_read, @@ -212,8 +212,8 @@ public: strict_write_ = strict_write; } - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + stdcxx::shared_ptr<Transport_> specific_trans = stdcxx::dynamic_pointer_cast<Transport_>(trans); TProtocol* prot; if (specific_trans) { prot = new TBinaryProtocolT<Transport_, ByteOrder_>(specific_trans, @@ -229,7 +229,7 @@ public: strict_write_); } - return boost::shared_ptr<TProtocol>(prot); + return stdcxx::shared_ptr<TProtocol>(prot); } private: http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TCompactProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h index d970be2..e6024a9 100644 --- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h +++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h @@ -23,7 +23,7 @@ #include <thrift/protocol/TVirtualProtocol.h> #include <stack> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -74,7 +74,7 @@ protected: int16_t lastFieldId_; public: - TCompactProtocolT(boost::shared_ptr<Transport_> trans) + TCompactProtocolT(stdcxx::shared_ptr<Transport_> trans) : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans), trans_(trans.get()), lastFieldId_(0), @@ -86,7 +86,7 @@ public: boolValue_.hasBoolValue = false; } - TCompactProtocolT(boost::shared_ptr<Transport_> trans, + TCompactProtocolT(stdcxx::shared_ptr<Transport_> trans, int32_t string_limit, int32_t container_limit) : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans), @@ -239,8 +239,8 @@ public: void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; } - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + stdcxx::shared_ptr<Transport_> specific_trans = stdcxx::dynamic_pointer_cast<Transport_>(trans); TProtocol* prot; if (specific_trans) { prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_, container_limit_); @@ -248,7 +248,7 @@ public: prot = new TCompactProtocol(trans, string_limit_, container_limit_); } - return boost::shared_ptr<TProtocol>(prot); + return stdcxx::shared_ptr<TProtocol>(prot); } private: http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TDebugProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h index cc93230..301d05a 100644 --- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h +++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h @@ -22,7 +22,7 @@ #include <thrift/protocol/TVirtualProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -51,7 +51,7 @@ private: enum write_state_t { UNINIT, STRUCT, LIST, SET, MAP_KEY, MAP_VALUE }; public: - TDebugProtocol(boost::shared_ptr<TTransport> trans) + TDebugProtocol(stdcxx::shared_ptr<TTransport> trans) : TVirtualProtocol<TDebugProtocol>(trans), trans_(trans.get()), string_limit_(DEFAULT_STRING_LIMIT), @@ -141,8 +141,8 @@ public: TDebugProtocolFactory() {} virtual ~TDebugProtocolFactory() {} - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TProtocol>(new TDebugProtocol(trans)); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TProtocol>(new TDebugProtocol(trans)); } }; } @@ -160,7 +160,7 @@ std::string ThriftDebugString(const ThriftStruct& ts) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TDebugProtocol protocol(trans); ts.write(&protocol); @@ -178,7 +178,7 @@ std::string DebugString(const std::vector<Object>& vec) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TDebugProtocol protocol(trans); // I am gross! http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp b/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp index 02dc736..2667617 100644 --- a/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/THeaderProtocol.cpp @@ -27,7 +27,7 @@ #include <limits> #include <boost/static_assert.hpp> -#include <boost/make_shared.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -42,11 +42,11 @@ void THeaderProtocol::resetProtocol() { switch (protoId_) { case T_BINARY_PROTOCOL: - proto_ = boost::make_shared<TBinaryProtocolT<THeaderTransport> >(trans_); + proto_ = stdcxx::make_shared<TBinaryProtocolT<THeaderTransport> >(trans_); break; case T_COMPACT_PROTOCOL: - proto_ = boost::make_shared<TCompactProtocolT<THeaderTransport> >(trans_); + proto_ = stdcxx::make_shared<TCompactProtocolT<THeaderTransport> >(trans_); break; default: http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/THeaderProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/THeaderProtocol.h b/lib/cpp/src/thrift/protocol/THeaderProtocol.h index b01bfb6..0b3997c 100644 --- a/lib/cpp/src/thrift/protocol/THeaderProtocol.h +++ b/lib/cpp/src/thrift/protocol/THeaderProtocol.h @@ -25,7 +25,7 @@ #include <thrift/protocol/TVirtualProtocol.h> #include <thrift/transport/THeaderTransport.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> using apache::thrift::transport::THeaderTransport; @@ -43,21 +43,21 @@ protected: public: void resetProtocol(); - explicit THeaderProtocol(const boost::shared_ptr<TTransport>& trans, + explicit THeaderProtocol(const stdcxx::shared_ptr<TTransport>& trans, uint16_t protoId = T_COMPACT_PROTOCOL) - : TVirtualProtocol<THeaderProtocol>(boost::shared_ptr<TTransport>(new THeaderTransport(trans))), - trans_(boost::dynamic_pointer_cast<THeaderTransport>(getTransport())), + : TVirtualProtocol<THeaderProtocol>(stdcxx::shared_ptr<TTransport>(new THeaderTransport(trans))), + trans_(stdcxx::dynamic_pointer_cast<THeaderTransport>(getTransport())), protoId_(protoId) { trans_->setProtocolId(protoId); resetProtocol(); } - THeaderProtocol(const boost::shared_ptr<TTransport>& inTrans, - const boost::shared_ptr<TTransport>& outTrans, + THeaderProtocol(const stdcxx::shared_ptr<TTransport>& inTrans, + const stdcxx::shared_ptr<TTransport>& outTrans, uint16_t protoId = T_COMPACT_PROTOCOL) : TVirtualProtocol<THeaderProtocol>( - boost::shared_ptr<TTransport>(new THeaderTransport(inTrans, outTrans))), - trans_(boost::dynamic_pointer_cast<THeaderTransport>(getTransport())), + stdcxx::shared_ptr<TTransport>(new THeaderTransport(inTrans, outTrans))), + trans_(stdcxx::dynamic_pointer_cast<THeaderTransport>(getTransport())), protoId_(protoId) { trans_->setProtocolId(protoId); resetProtocol(); @@ -182,25 +182,25 @@ public: uint32_t readBinary(std::string& binary); protected: - boost::shared_ptr<THeaderTransport> trans_; + stdcxx::shared_ptr<THeaderTransport> trans_; - boost::shared_ptr<TProtocol> proto_; + stdcxx::shared_ptr<TProtocol> proto_; uint32_t protoId_; }; class THeaderProtocolFactory : public TProtocolFactory { public: - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<transport::TTransport> trans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<transport::TTransport> trans) { THeaderProtocol* headerProtocol - = new THeaderProtocol(trans, boost::shared_ptr<transport::TTransport>(), T_BINARY_PROTOCOL); - return boost::shared_ptr<TProtocol>(headerProtocol); + = new THeaderProtocol(trans, stdcxx::shared_ptr<transport::TTransport>(), T_BINARY_PROTOCOL); + return stdcxx::shared_ptr<TProtocol>(headerProtocol); } - virtual boost::shared_ptr<TProtocol> getProtocol( - boost::shared_ptr<transport::TTransport> inTrans, - boost::shared_ptr<transport::TTransport> outTrans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol( + stdcxx::shared_ptr<transport::TTransport> inTrans, + stdcxx::shared_ptr<transport::TTransport> outTrans) { THeaderProtocol* headerProtocol = new THeaderProtocol(inTrans, outTrans, T_BINARY_PROTOCOL); - return boost::shared_ptr<TProtocol>(headerProtocol); + return stdcxx::shared_ptr<TProtocol>(headerProtocol); } }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp index 943d960..bbba260 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp @@ -398,7 +398,7 @@ private: bool first_; }; -TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) +TJSONProtocol::TJSONProtocol(stdcxx::shared_ptr<TTransport> ptrans) : TVirtualProtocol<TJSONProtocol>(ptrans), trans_(ptrans.get()), context_(new TJSONContext()), @@ -408,7 +408,7 @@ TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) TJSONProtocol::~TJSONProtocol() { } -void TJSONProtocol::pushContext(boost::shared_ptr<TJSONContext> c) { +void TJSONProtocol::pushContext(stdcxx::shared_ptr<TJSONContext> c) { contexts_.push(context_); context_ = c; } @@ -576,7 +576,7 @@ uint32_t TJSONProtocol::writeJSONDouble(double num) { uint32_t TJSONProtocol::writeJSONObjectStart() { uint32_t result = context_->write(*trans_); trans_->write(&kJSONObjectStart, 1); - pushContext(boost::shared_ptr<TJSONContext>(new JSONPairContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONPairContext())); return result + 1; } @@ -589,7 +589,7 @@ uint32_t TJSONProtocol::writeJSONObjectEnd() { uint32_t TJSONProtocol::writeJSONArrayStart() { uint32_t result = context_->write(*trans_); trans_->write(&kJSONArrayStart, 1); - pushContext(boost::shared_ptr<TJSONContext>(new JSONListContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONListContext())); return result + 1; } @@ -923,7 +923,7 @@ uint32_t TJSONProtocol::readJSONDouble(double& num) { uint32_t TJSONProtocol::readJSONObjectStart() { uint32_t result = context_->read(reader_); result += readJSONSyntaxChar(kJSONObjectStart); - pushContext(boost::shared_ptr<TJSONContext>(new JSONPairContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONPairContext())); return result; } @@ -936,7 +936,7 @@ uint32_t TJSONProtocol::readJSONObjectEnd() { uint32_t TJSONProtocol::readJSONArrayStart() { uint32_t result = context_->read(reader_); result += readJSONSyntaxChar(kJSONArrayStart); - pushContext(boost::shared_ptr<TJSONContext>(new JSONListContext())); + pushContext(stdcxx::shared_ptr<TJSONContext>(new JSONListContext())); return result; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TJSONProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h index 5a94624..16dff56 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h @@ -96,12 +96,12 @@ class TJSONContext; */ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> { public: - TJSONProtocol(boost::shared_ptr<TTransport> ptrans); + TJSONProtocol(stdcxx::shared_ptr<TTransport> ptrans); ~TJSONProtocol(); private: - void pushContext(boost::shared_ptr<TJSONContext> c); + void pushContext(stdcxx::shared_ptr<TJSONContext> c); void popContext(); @@ -276,8 +276,8 @@ public: private: TTransport* trans_; - std::stack<boost::shared_ptr<TJSONContext> > contexts_; - boost::shared_ptr<TJSONContext> context_; + std::stack<stdcxx::shared_ptr<TJSONContext> > contexts_; + stdcxx::shared_ptr<TJSONContext> context_; LookaheadReader reader_; }; @@ -290,8 +290,8 @@ public: virtual ~TJSONProtocolFactory() {} - boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { - return boost::shared_ptr<TProtocol>(new TJSONProtocol(trans)); + stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) { + return stdcxx::shared_ptr<TProtocol>(new TJSONProtocol(trans)); } }; } @@ -309,7 +309,7 @@ std::string ThriftJSONString(const ThriftStruct& ts) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; TMemoryBuffer* buffer = new TMemoryBuffer; - boost::shared_ptr<TTransport> trans(buffer); + stdcxx::shared_ptr<TTransport> trans(buffer); TJSONProtocol protocol(trans); ts.write(&protocol); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h index 0244fbe..dd7e88f 100644 --- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h +++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h @@ -25,7 +25,7 @@ namespace apache { namespace thrift { namespace protocol { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index 276cefa..2a9d07b 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -28,7 +28,7 @@ #include <thrift/transport/TTransport.h> #include <thrift/protocol/TProtocolException.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <boost/static_assert.hpp> #ifdef HAVE_NETINET_IN_H @@ -550,12 +550,12 @@ public: } virtual uint32_t skip_virt(TType type); - inline boost::shared_ptr<TTransport> getTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getTransport() { return ptrans_; } // TODO: remove these two calls, they are for backwards // compatibility - inline boost::shared_ptr<TTransport> getInputTransport() { return ptrans_; } - inline boost::shared_ptr<TTransport> getOutputTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getInputTransport() { return ptrans_; } + inline stdcxx::shared_ptr<TTransport> getOutputTransport() { return ptrans_; } // input and output recursion depth are kept separate so that one protocol // can be used concurrently for both input and output. @@ -577,11 +577,11 @@ public: void setRecurisionLimit(uint32_t depth) {recursion_limit_ = depth;} protected: - TProtocol(boost::shared_ptr<TTransport> ptrans) + TProtocol(stdcxx::shared_ptr<TTransport> ptrans) : ptrans_(ptrans), input_recursion_depth_(0), output_recursion_depth_(0), recursion_limit_(DEFAULT_RECURSION_LIMIT) {} - boost::shared_ptr<TTransport> ptrans_; + stdcxx::shared_ptr<TTransport> ptrans_; private: TProtocol() {} @@ -599,9 +599,9 @@ public: virtual ~TProtocolFactory(); - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) = 0; - virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> inTrans, - boost::shared_ptr<TTransport> outTrans) { + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> trans) = 0; + virtual stdcxx::shared_ptr<TProtocol> getProtocol(stdcxx::shared_ptr<TTransport> inTrans, + stdcxx::shared_ptr<TTransport> outTrans) { (void)outTrans; return getProtocol(inTrans); } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TProtocolDecorator.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h index 446a81f..a353b79 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h +++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h @@ -21,12 +21,12 @@ #define THRIFT_TPROTOCOLDECORATOR_H_ 1 #include <thrift/protocol/TProtocol.h> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { namespace protocol { -using boost::shared_ptr; +using stdcxx::shared_ptr; /** * <code>TProtocolDecorator</code> forwards all requests to an enclosed http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TProtocolTap.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TProtocolTap.h b/lib/cpp/src/thrift/protocol/TProtocolTap.h index 3e56393..176d4fd 100644 --- a/lib/cpp/src/thrift/protocol/TProtocolTap.h +++ b/lib/cpp/src/thrift/protocol/TProtocolTap.h @@ -36,7 +36,7 @@ using apache::thrift::transport::TTransport; */ class TProtocolTap : public TVirtualProtocol<TProtocolTap> { public: - TProtocolTap(boost::shared_ptr<TProtocol> source, boost::shared_ptr<TProtocol> sink) + TProtocolTap(stdcxx::shared_ptr<TProtocol> source, stdcxx::shared_ptr<TProtocol> sink) : TVirtualProtocol<TProtocolTap>(source->getTransport()), source_(source), sink_(sink) {} uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) { @@ -167,8 +167,8 @@ public: } private: - boost::shared_ptr<TProtocol> source_; - boost::shared_ptr<TProtocol> sink_; + stdcxx::shared_ptr<TProtocol> source_; + stdcxx::shared_ptr<TProtocol> sink_; }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/protocol/TVirtualProtocol.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h index 831c3a2..628b494 100644 --- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h +++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h @@ -301,7 +301,7 @@ public: uint32_t skip(TType type) { return ::apache::thrift::protocol::skip(*this, type); } protected: - TProtocolDefaults(boost::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {} + TProtocolDefaults(stdcxx::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {} }; /** @@ -504,7 +504,7 @@ public: using Super_::readBool; // so we don't hide readBool(bool&) protected: - TVirtualProtocol(boost::shared_ptr<TTransport> ptrans) : Super_(ptrans) {} + TVirtualProtocol(stdcxx::shared_ptr<TTransport> ptrans) : Super_(ptrans) {} }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp index 686f242..cd38b01 100644 --- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp +++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp @@ -23,11 +23,13 @@ #include <QIODevice> #include <thrift/transport/TBufferTransports.h> - -using boost::shared_ptr; +#include <thrift/stdcxx.h> namespace apache { namespace thrift { + +using stdcxx::shared_ptr; + namespace transport { TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev) : dev_(dev) { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/qt/TQIODeviceTransport.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h index 8091d32..9087f2c 100644 --- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h +++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ #define _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/transport/TVirtualTransport.h> @@ -36,7 +36,7 @@ namespace transport { class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> { public: - explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev); + explicit TQIODeviceTransport(stdcxx::shared_ptr<QIODevice> dev); virtual ~TQIODeviceTransport(); void open(); @@ -59,7 +59,7 @@ private: TQIODeviceTransport(const TQIODeviceTransport&); TQIODeviceTransport& operator=(const TQIODeviceTransport&); - boost::shared_ptr<QIODevice> dev_; + stdcxx::shared_ptr<QIODevice> dev_; }; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/qt/TQTcpServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.cpp b/lib/cpp/src/thrift/qt/TQTcpServer.cpp index 350198c..c4669d7 100644 --- a/lib/cpp/src/thrift/qt/TQTcpServer.cpp +++ b/lib/cpp/src/thrift/qt/TQTcpServer.cpp @@ -23,19 +23,20 @@ #include <QMetaType> #include <QTcpSocket> -#include <thrift/cxxfunctional.h> +#include <thrift/stdcxx.h> #include <thrift/protocol/TProtocol.h> #include <thrift/async/TAsyncProcessor.h> -using boost::shared_ptr; using apache::thrift::protocol::TProtocol; using apache::thrift::protocol::TProtocolFactory; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TQIODeviceTransport; -using apache::thrift::stdcxx::function; using apache::thrift::stdcxx::bind; +using apache::thrift::stdcxx::function; +using apache::thrift::stdcxx::placeholders::_1; +using apache::thrift::stdcxx::shared_ptr; QT_USE_NAMESPACE @@ -110,7 +111,7 @@ void TQTcpServer::beginDecode() { try { processor_ - ->process(bind(&TQTcpServer::finish, this, ctx, apache::thrift::stdcxx::placeholders::_1), + ->process(bind(&TQTcpServer::finish, this, ctx, _1), ctx->iprot_, ctx->oprot_); } catch (const TTransportException& ex) { http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/qt/TQTcpServer.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.h b/lib/cpp/src/thrift/qt/TQTcpServer.h index 081d84a..0d32afa 100644 --- a/lib/cpp/src/thrift/qt/TQTcpServer.h +++ b/lib/cpp/src/thrift/qt/TQTcpServer.h @@ -23,7 +23,7 @@ #include <QObject> #include <QTcpServer> -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> namespace apache { namespace thrift { @@ -47,9 +47,9 @@ class TAsyncProcessor; class TQTcpServer : public QObject { Q_OBJECT public: - TQTcpServer(boost::shared_ptr<QTcpServer> server, - boost::shared_ptr<TAsyncProcessor> processor, - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, + TQTcpServer(stdcxx::shared_ptr<QTcpServer> server, + stdcxx::shared_ptr<TAsyncProcessor> processor, + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory, QObject* parent = NULL); virtual ~TQTcpServer(); @@ -65,13 +65,13 @@ private: struct ConnectionContext; void scheduleDeleteConnectionContext(QTcpSocket* connection); - void finish(boost::shared_ptr<ConnectionContext> ctx, bool healthy); + void finish(stdcxx::shared_ptr<ConnectionContext> ctx, bool healthy); - boost::shared_ptr<QTcpServer> server_; - boost::shared_ptr<TAsyncProcessor> processor_; - boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; + stdcxx::shared_ptr<QTcpServer> server_; + stdcxx::shared_ptr<TAsyncProcessor> processor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_; - typedef std::map<QTcpSocket*, boost::shared_ptr<ConnectionContext> > ConnectionContextMap; + typedef std::map<QTcpSocket*, stdcxx::shared_ptr<ConnectionContext> > ConnectionContextMap; ConnectionContextMap ctxMap_; }; } http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/server/TConnectedClient.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TConnectedClient.cpp b/lib/cpp/src/thrift/server/TConnectedClient.cpp index 889c885..33ec3a9 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.cpp +++ b/lib/cpp/src/thrift/server/TConnectedClient.cpp @@ -28,7 +28,7 @@ using apache::thrift::protocol::TProtocol; using apache::thrift::server::TServerEventHandler; using apache::thrift::transport::TTransport; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using stdcxx::shared_ptr; using std::string; TConnectedClient::TConnectedClient(const shared_ptr<TProcessor>& processor, http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/server/TConnectedClient.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TConnectedClient.h b/lib/cpp/src/thrift/server/TConnectedClient.h index 3ea065e..2f9d4c9 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.h +++ b/lib/cpp/src/thrift/server/TConnectedClient.h @@ -20,7 +20,7 @@ #ifndef _THRIFT_SERVER_TCONNECTEDCLIENT_H_ #define _THRIFT_SERVER_TCONNECTEDCLIENT_H_ 1 -#include <boost/shared_ptr.hpp> +#include <thrift/stdcxx.h> #include <thrift/TProcessor.h> #include <thrift/protocol/TProtocol.h> #include <thrift/server/TServer.h> @@ -49,11 +49,11 @@ public: * @param[in] client the TTransport representing the client */ TConnectedClient( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, - const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, - const boost::shared_ptr<apache::thrift::transport::TTransport>& client); + const stdcxx::shared_ptr<apache::thrift::TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, + const stdcxx::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, + const stdcxx::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, + const stdcxx::shared_ptr<apache::thrift::transport::TTransport>& client); /** * Destructor. @@ -92,11 +92,11 @@ protected: virtual void cleanup(); private: - boost::shared_ptr<apache::thrift::TProcessor> processor_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; - boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; - boost::shared_ptr<apache::thrift::transport::TTransport> client_; + stdcxx::shared_ptr<apache::thrift::TProcessor> processor_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; + stdcxx::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; + stdcxx::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; + stdcxx::shared_ptr<apache::thrift::transport::TTransport> client_; /** * Context acquired from the eventHandler_ if one exists. http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/server/TNonblockingServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp index d5af12a..d17f77c 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp +++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp @@ -25,6 +25,7 @@ #include <thrift/concurrency/PlatformThreadFactory.h> #include <thrift/transport/PlatformSocket.h> +#include <algorithm> #include <iostream> #ifdef HAVE_SYS_SELECT_H @@ -77,10 +78,9 @@ namespace server { using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace apache::thrift::concurrency; -using namespace std; using apache::thrift::transport::TSocket; using apache::thrift::transport::TTransportException; -using boost::shared_ptr; +using stdcxx::shared_ptr; /// Three states for sockets: recv frame size, recv data, and send mode enum TSocketState { SOCKET_RECV_FRAMING, SOCKET_RECV, SOCKET_SEND }; @@ -115,10 +115,10 @@ private: TNonblockingServer* server_; /// TProcessor - boost::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProcessor> processor_; /// Object wrapping network socket - boost::shared_ptr<TSocket> tSocket_; + stdcxx::shared_ptr<TSocket> tSocket_; /// Libevent object struct event event_; @@ -160,23 +160,23 @@ private: int32_t callsForResize_; /// Transport to read from - boost::shared_ptr<TMemoryBuffer> inputTransport_; + stdcxx::shared_ptr<TMemoryBuffer> inputTransport_; /// Transport that processor writes to - boost::shared_ptr<TMemoryBuffer> outputTransport_; + stdcxx::shared_ptr<TMemoryBuffer> outputTransport_; /// extra transport generated by transport factory (e.g. BufferedRouterTransport) - boost::shared_ptr<TTransport> factoryInputTransport_; - boost::shared_ptr<TTransport> factoryOutputTransport_; + stdcxx::shared_ptr<TTransport> factoryInputTransport_; + stdcxx::shared_ptr<TTransport> factoryOutputTransport_; /// Protocol decoder - boost::shared_ptr<TProtocol> inputProtocol_; + stdcxx::shared_ptr<TProtocol> inputProtocol_; /// Protocol encoder - boost::shared_ptr<TProtocol> outputProtocol_; + stdcxx::shared_ptr<TProtocol> outputProtocol_; /// Server event handler, if any - boost::shared_ptr<TServerEventHandler> serverEventHandler_; + stdcxx::shared_ptr<TServerEventHandler> serverEventHandler_; /// Thrift call context, if any void* connectionContext_; @@ -209,7 +209,7 @@ public: class Task; /// Constructor - TConnection(boost::shared_ptr<TSocket> socket, + TConnection(stdcxx::shared_ptr<TSocket> socket, TNonblockingIOThread* ioThread) { readBuffer_ = NULL; readBufferSize_ = 0; @@ -245,7 +245,7 @@ public: void init(TNonblockingIOThread* ioThread); /// set socket for connection - void setSocket(boost::shared_ptr<TSocket> socket); + void setSocket(stdcxx::shared_ptr<TSocket> socket); /** * This is called when the application transitions from one state into @@ -301,10 +301,10 @@ public: TAppState getState() const { return appState_; } /// return the TSocket transport wrapping this network connection - boost::shared_ptr<TSocket> getTSocket() const { return tSocket_; } + stdcxx::shared_ptr<TSocket> getTSocket() const { return tSocket_; } /// return the server event handler if any - boost::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } + stdcxx::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; } /// return the Thrift connection context if any void* getConnectionContext() { return connectionContext_; } @@ -312,9 +312,9 @@ public: class TNonblockingServer::TConnection::Task : public Runnable { public: - Task(boost::shared_ptr<TProcessor> processor, - boost::shared_ptr<TProtocol> input, - boost::shared_ptr<TProtocol> output, + Task(stdcxx::shared_ptr<TProcessor> processor, + stdcxx::shared_ptr<TProtocol> input, + stdcxx::shared_ptr<TProtocol> output, TConnection* connection) : processor_(processor), input_(input), @@ -336,7 +336,7 @@ public: } } catch (const TTransportException& ttx) { GlobalOutput.printf("TNonblockingServer: client died: %s", ttx.what()); - } catch (const bad_alloc&) { + } catch (const std::bad_alloc&) { GlobalOutput("TNonblockingServer: caught bad_alloc exception."); exit(1); } catch (const std::exception& x) { @@ -359,11 +359,11 @@ public: TConnection* getTConnection() { return connection_; } private: - boost::shared_ptr<TProcessor> processor_; - boost::shared_ptr<TProtocol> input_; - boost::shared_ptr<TProtocol> output_; + stdcxx::shared_ptr<TProcessor> processor_; + stdcxx::shared_ptr<TProtocol> input_; + stdcxx::shared_ptr<TProtocol> output_; TConnection* connection_; - boost::shared_ptr<TServerEventHandler> serverEventHandler_; + stdcxx::shared_ptr<TServerEventHandler> serverEventHandler_; void* connectionContext_; }; @@ -410,7 +410,7 @@ void TNonblockingServer::TConnection::init(TNonblockingIOThread* ioThread) { processor_ = server_->getProcessor(inputProtocol_, outputProtocol_, tSocket_); } -void TNonblockingServer::TConnection::setSocket(boost::shared_ptr<TSocket> socket) { +void TNonblockingServer::TConnection::setSocket(stdcxx::shared_ptr<TSocket> socket) { tSocket_ = socket; } @@ -594,7 +594,7 @@ void TNonblockingServer::TConnection::transition() { // We are setting up a Task to do this work and we will wait on it // Create task and dispatch to the thread manager - boost::shared_ptr<Runnable> task = boost::shared_ptr<Runnable>( + stdcxx::shared_ptr<Runnable> task = stdcxx::shared_ptr<Runnable>( new Task(processor_, inputProtocol_, outputProtocol_, this)); // The application is now waiting on the task to finish appState_ = APP_WAIT_TASK; @@ -879,9 +879,9 @@ TNonblockingServer::~TNonblockingServer() { // objects and the Thread objects have shared_ptrs to the TNonblockingIOThread // objects (as runnable) so these objects will never deallocate without help. while (!ioThreads_.empty()) { - boost::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back(); + stdcxx::shared_ptr<TNonblockingIOThread> iot = ioThreads_.back(); ioThreads_.pop_back(); - iot->setThread(boost::shared_ptr<Thread>()); + iot->setThread(stdcxx::shared_ptr<Thread>()); } } @@ -889,7 +889,7 @@ TNonblockingServer::~TNonblockingServer() { * Creates a new connection either by reusing an object off the stack or * by allocating a new one entirely */ -TNonblockingServer::TConnection* TNonblockingServer::createConnection(boost::shared_ptr<TSocket> socket) { +TNonblockingServer::TConnection* TNonblockingServer::createConnection(stdcxx::shared_ptr<TSocket> socket) { // Check the stack Guard g(connMutex_); @@ -945,7 +945,7 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) { assert(fd == serverSocket_); // Going to accept a new client socket - boost::shared_ptr<TSocket> clientSocket; + stdcxx::shared_ptr<TSocket> clientSocket; clientSocket = serverTransport_->accept(); if (clientSocket) { @@ -1008,7 +1008,7 @@ void TNonblockingServer::createAndListenOnSocket() { } -void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) { +void TNonblockingServer::setThreadManager(stdcxx::shared_ptr<ThreadManager> threadManager) { threadManager_ = threadManager; if (threadManager) { threadManager->setExpireCallback( @@ -1046,7 +1046,7 @@ bool TNonblockingServer::serverOverloaded() { bool TNonblockingServer::drainPendingTask() { if (threadManager_) { - boost::shared_ptr<Runnable> task = threadManager_->removeNextPending(); + stdcxx::shared_ptr<Runnable> task = threadManager_->removeNextPending(); if (task) { TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection(); assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK); @@ -1057,7 +1057,7 @@ bool TNonblockingServer::drainPendingTask() { return false; } -void TNonblockingServer::expireClose(boost::shared_ptr<Runnable> task) { +void TNonblockingServer::expireClose(stdcxx::shared_ptr<Runnable> task) { TConnection* connection = static_cast<TConnection::Task*>(task.get())->getTConnection(); assert(connection && connection->getServer() && connection->getState() == APP_WAIT_TASK); connection->forceClose(); http://git-wip-us.apache.org/repos/asf/thrift/blob/82ae9575/lib/cpp/src/thrift/server/TNonblockingServer.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h index 1f60048..f95a729 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.h +++ b/lib/cpp/src/thrift/server/TNonblockingServer.h @@ -21,6 +21,7 @@ #define _THRIFT_SERVER_TNONBLOCKINGSERVER_H_ 1 #include <thrift/Thrift.h> +#include <thrift/stdcxx.h> #include <thrift/server/TServer.h> #include <thrift/transport/PlatformSocket.h> #include <thrift/transport/TBufferTransports.h> @@ -159,16 +160,16 @@ private: event_base* userEventBase_; /// For processing via thread pool, may be NULL - boost::shared_ptr<ThreadManager> threadManager_; + stdcxx::shared_ptr<ThreadManager> threadManager_; /// Is thread pool processing? bool threadPoolProcessing_; // Factory to create the IO threads - boost::shared_ptr<PlatformThreadFactory> ioThreadFactory_; + stdcxx::shared_ptr<PlatformThreadFactory> ioThreadFactory_; // Vector of IOThread objects that will handle our IO - std::vector<boost::shared_ptr<TNonblockingIOThread> > ioThreads_; + std::vector<stdcxx::shared_ptr<TNonblockingIOThread> > ioThreads_; // Index of next IO Thread to be used (for round-robin) uint32_t nextIOThread_; @@ -263,7 +264,7 @@ private: /* */ - boost::shared_ptr<TNonblockingServerTransport> serverTransport_; + stdcxx::shared_ptr<TNonblockingServerTransport> serverTransport_; /** * Called when server socket had something happen. We accept all waiting @@ -300,26 +301,25 @@ private: } public: - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) : TServer(processorFactory), serverTransport_(serverTransport) { init(); } - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport) : TServer(processor), serverTransport_(serverTransport) { init(); } - - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) - : TServer(processorFactory), serverTransport_(serverTransport) { + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) + : TServer(processorFactory), serverTransport_(serverTransport) { init(); setInputProtocolFactory(protocolFactory); @@ -327,14 +327,12 @@ public: setThreadManager(threadManager); } - - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TProtocolFactory>& protocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TProtocolFactory>& protocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processor), serverTransport_(serverTransport) { - init(); setInputProtocolFactory(protocolFactory); @@ -342,16 +340,15 @@ public: setThreadManager(threadManager); } - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessorFactory>& processorFactory, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processorFactory), serverTransport_(serverTransport) { - init(); setInputTransportFactory(inputTransportFactory); @@ -361,16 +358,15 @@ public: setThreadManager(threadManager); } - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - const boost::shared_ptr<TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, - const boost::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, - const boost::shared_ptr<ThreadManager>& threadManager - = boost::shared_ptr<ThreadManager>()) + TNonblockingServer(const stdcxx::shared_ptr<TProcessor>& processor, + const stdcxx::shared_ptr<TTransportFactory>& inputTransportFactory, + const stdcxx::shared_ptr<TTransportFactory>& outputTransportFactory, + const stdcxx::shared_ptr<TProtocolFactory>& inputProtocolFactory, + const stdcxx::shared_ptr<TProtocolFactory>& outputProtocolFactory, + const stdcxx::shared_ptr<apache::thrift::transport::TNonblockingServerTransport>& serverTransport, + const stdcxx::shared_ptr<ThreadManager>& threadManager + = stdcxx::shared_ptr<ThreadManager>()) : TServer(processor), serverTransport_(serverTransport) { - init(); setInputTransportFactory(inputTransportFactory); @@ -382,11 +378,11 @@ public: ~TNonblockingServer(); - void setThreadManager(boost::shared_ptr<ThreadManager> threadManager); + void setThreadManager(stdcxx::shared_ptr<ThreadManager> threadManager); int getListenPort() { return serverTransport_->getListenPort(); } - boost::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; } + stdcxx::shared_ptr<ThreadManager> getThreadManager() { return threadManager_; } /** * Sets the number of IO threads used by this server. Can only be used before @@ -425,7 +421,7 @@ public: bool isThreadPoolProcessing() const { return threadPoolProcessing_; } - void addTask(boost::shared_ptr<Runnable> task) { + void addTask(stdcxx::shared_ptr<Runnable> task) { threadManager_->add(task, 0LL, taskExpireTime_); } @@ -684,7 +680,7 @@ public: /// Creates a socket to listen on and binds it to the local port. void createAndListenOnSocket(); - + /** * Register the optional user-provided event-base (for single-thread servers) * @@ -713,7 +709,7 @@ private: * * @param task the runnable associated with the expired task. */ - void expireClose(boost::shared_ptr<Runnable> task); + void expireClose(stdcxx::shared_ptr<Runnable> task); /** * Return an initialized connection object. Creates or recovers from @@ -725,7 +721,7 @@ private: * @param addrLen the length of addr * @return pointer to initialized TConnection object. */ - TConnection* createConnection(boost::shared_ptr<TSocket> socket); + TConnection* createConnection(stdcxx::shared_ptr<TSocket> socket); /** * Returns a connection to pool or deletion. If the connection pool @@ -769,10 +765,10 @@ public: evutil_socket_t getNotificationRecvFD() const { return notificationPipeFDs_[0]; } // Returns the actual thread object associated with this IO thread. - boost::shared_ptr<Thread> getThread() const { return thread_; } + stdcxx::shared_ptr<Thread> getThread() const { return thread_; } // Sets the actual thread object associated with this IO thread. - void setThread(const boost::shared_ptr<Thread>& t) { thread_ = t; } + void setThread(const stdcxx::shared_ptr<Thread>& t) { thread_ = t; } // Used by TConnection objects to indicate processing has finished. bool notify(TNonblockingServer::TConnection* conn); @@ -857,7 +853,7 @@ private: evutil_socket_t notificationPipeFDs_[2]; /// Actual IO Thread - boost::shared_ptr<Thread> thread_; + stdcxx::shared_ptr<Thread> thread_; }; } }