Converted concurrency classes to use boost::shared_ptr and boost::weak_ptr:
Wrapped all thrift code in facebook::thrift:: namespace
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664735 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/TimerManager.h b/lib/cpp/src/concurrency/TimerManager.h
index 2b92f23..c0e6340 100644
--- a/lib/cpp/src/concurrency/TimerManager.h
+++ b/lib/cpp/src/concurrency/TimerManager.h
@@ -5,12 +5,16 @@
#include "Monitor.h"
#include "Thread.h"
+#include <boost/shared_ptr.hpp>
+
#include <map>
#include <time.h>
namespace facebook { namespace thrift { namespace concurrency {
+using namespace boost;
+
/** Timer Manager
This class dispatches timer tasks when they fall due.
@@ -26,9 +30,9 @@
virtual ~TimerManager();
- virtual const ThreadFactory* threadFactory() const;
+ virtual shared_ptr<const ThreadFactory> threadFactory() const;
- virtual void threadFactory(const ThreadFactory* value);
+ virtual void threadFactory(shared_ptr<const ThreadFactory> value);
/** Starts the timer manager service
@@ -47,14 +51,14 @@
@param task The task to execute
@param timeout Time in milliseconds to delay before executing task */
- virtual void add(Runnable* task, long long timeout);
+ virtual void add(shared_ptr<Runnable> task, long long timeout);
/** Adds a task to be executed at some time in the future by a worker thread.
@param task The task to execute
@param timeout Absolute time in the future to execute task. */
- virtual void add(Runnable* task, const struct timespec& timeout);
+ virtual void add(shared_ptr<Runnable> task, const struct timespec& timeout);
/** Removes a pending task
@@ -63,7 +67,7 @@
@throws UncancellableTaskException Specified task is already being executed or has completed execution. */
- virtual void remove(Runnable* task);
+ virtual void remove(shared_ptr<Runnable> task);
enum STATE {
UNINITIALIZED,
@@ -77,13 +81,13 @@
private:
- const ThreadFactory* _threadFactory;
+ shared_ptr<const ThreadFactory> _threadFactory;
class Task;
friend class Task;
- std::multimap<long long, Task*> _taskMap;
+ std::multimap<long long, shared_ptr<Task> > _taskMap;
size_t _taskCount;
@@ -95,9 +99,9 @@
friend class Dispatcher;
- Dispatcher* _dispatcher;
+ shared_ptr<Dispatcher> _dispatcher;
- Thread* _dispatcherThread;
+ shared_ptr<Thread> _dispatcherThread;
};