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/Monitor.cc b/lib/cpp/src/concurrency/Monitor.cc
index d1b83d1..a2e4276 100644
--- a/lib/cpp/src/concurrency/Monitor.cc
+++ b/lib/cpp/src/concurrency/Monitor.cc
@@ -1,15 +1,17 @@
 #include "Monitor.h" 
+#include "Util.h"
 
 #include <assert.h>
 #include <errno.h>
 #include <pthread.h>
 
+
 namespace facebook { namespace thrift { namespace concurrency { 
 
 /** Monitor implementation using the POSIX pthread library
     
     @author marc
-    @version $Id$ */
+    @version $Id:$ */
 
 class Monitor::Impl {
 
@@ -61,7 +63,7 @@
 
       struct timespec abstime;
 
-      toAbsoluteTimespec(abstime, timeout);
+      Util::toAbsoluteTimespec(abstime, timeout);
 
       int result  = pthread_cond_timedwait(&_pthread_cond, &_pthread_mutex, &abstime);
 
@@ -88,29 +90,6 @@
 
 private:
 
-  /** Converts relative timeout specified as a duration in milliseconds to a struct timespec structure
-      specifying current time plus timeout 
-
-      @param timeout time to delay in milliseconds
-      @return struct timespec current time plus timeout  */
-
-  static const void toAbsoluteTimespec(struct timespec& result, long long timeout) {
-
-    // XXX Darwin doesn't seem to have any readily useable hi-res clock.
-
-    time_t seconds; 
-
-    assert(time(&seconds) != (time_t)-1);
-
-    seconds+= (timeout / 1000);
-
-    long nanoseconds = (timeout % 1000) * 1000000;
-
-    result.tv_sec = seconds + (nanoseconds / 1000000000);
-
-    result.tv_nsec = nanoseconds % 1000000000;
-  }
-
   mutable pthread_mutex_t _pthread_mutex;
 
   mutable bool mutexInitialized;