Another checkpoint of initial cut at thread pool manager for thrift and related concurrency classes.
Added TimerManager - I can't live without one after all.
Added Util - handy place for common time operations et al.
Initial test code
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664722 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/TimerManager.h b/lib/cpp/src/concurrency/TimerManager.h
new file mode 100644
index 0000000..002460a
--- /dev/null
+++ b/lib/cpp/src/concurrency/TimerManager.h
@@ -0,0 +1,77 @@
+#if !defined(_concurrency_TimerManager_h_)
+#define _concurrency_TimerManager_h_ 1
+
+#include "Monitor.h"
+#include "Thread.h"
+
+#include <map>
+
+#include <time.h>
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+/** Timer Manager
+
+ This class dispatches timer tasks when they fall due.
+
+ @author marc
+ @version $Id:$ */
+
+class TimerManager {
+
+ public:
+
+ TimerManager();
+
+ virtual ~TimerManager() = 0;
+
+ virtual const ThreadFactory* threadFactory() const = 0;
+
+ virtual void threadFactory(const ThreadFactory* value) = 0;
+
+ virtual size_t taskCount() const = 0;
+
+ /** Adds a task to be executed at some time in the future by a worker thread.
+
+ @param task The task to execute
+ @param timeout Time in milliseconds to delay before executing task */
+
+ virtual void add(Runnable* task, long long timeout) = 0;
+
+ /** 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) = 0;
+
+ /** Removes a pending task */
+
+ virtual void remove(Runnable* task) = 0;
+
+ private:
+
+ const ThreadFactory* _threadFactory;
+
+ class Task;
+
+ friend class Task;
+
+ std::multimap<long long, Task*> _taskMap;
+
+ size_t _taskCount;
+
+ long long _nextTimeout;
+
+ Monitor _monitor;
+
+ class Dispatcher;
+
+ friend class Dispatcher;
+
+ Dispatcher* _dispatcher;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // !defined(_concurrency_TimerManager_h_)