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/test/ThreadManagerTests.h b/lib/cpp/src/concurrency/test/ThreadManagerTests.h
index 8b2dda8..7e74aac 100644
--- a/lib/cpp/src/concurrency/test/ThreadManagerTests.h
+++ b/lib/cpp/src/concurrency/test/ThreadManagerTests.h
@@ -1,8 +1,8 @@
 #include <config.h>
-#include <ThreadManager.h>
-#include <PosixThreadFactory.h>
-#include <Monitor.h>
-#include <Util.h>
+#include <concurrency/ThreadManager.h>
+#include <concurrency/PosixThreadFactory.h>
+#include <concurrency/Monitor.h>
+#include <concurrency/Util.h>
 
 #include <assert.h>
 #include <set>
@@ -23,6 +23,8 @@
 
 public:
 
+  static const double ERROR;
+
   class Task: public Runnable {
 
   public:
@@ -78,9 +80,9 @@
 
     size_t activeCount = count;
 
-    ThreadManager* threadManager = ThreadManager::newSimpleThreadManager(workerCount);
+    shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
 
-    PosixThreadFactory* threadFactory = new PosixThreadFactory();
+    shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
 
     threadFactory->priority(PosixThreadFactory::HIGHEST);
       
@@ -88,16 +90,16 @@
 
     threadManager->start();
       
-    std::set<ThreadManagerTests::Task*> tasks;
+    std::set<shared_ptr<ThreadManagerTests::Task> > tasks;
 
     for(size_t ix = 0; ix < count; ix++) {
 
-      tasks.insert(new ThreadManagerTests::Task(monitor, activeCount, timeout));
+      tasks.insert(shared_ptr<ThreadManagerTests::Task>(new ThreadManagerTests::Task(monitor, activeCount, timeout)));
     }
 
     long long time00 = Util::currentTime();
 
-    for(std::set<ThreadManagerTests::Task*>::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for(std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
 
 	threadManager->add(*ix);
     }
@@ -119,9 +121,9 @@
     long long minTime = 9223372036854775807LL;
     long long maxTime = 0;
 
-    for(std::set<ThreadManagerTests::Task*>::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for(std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
       
-      ThreadManagerTests::Task* task = *ix;
+      shared_ptr<ThreadManagerTests::Task> task = *ix;
 
       long long delta = task->_endTime - task->_startTime;
 
@@ -144,8 +146,6 @@
       }
 
       averageTime+= delta;
-
-      delete *ix;
     }
     
     averageTime /= count;
@@ -160,18 +160,16 @@
       error*= -1.0;
     }
 
-    bool success = error < .10;
-
-    delete threadManager;
-
-    delete threadFactory;
+    bool success = error < ERROR;
 
     std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << expectedTime << "ms elapsed time: "<< time01 - time00 << "ms error%: " << error * 100.0 << std::endl;
 
     return success;
   }
 };
-  
+
+const double ThreadManagerTests::ERROR = .20;
+
 }}}} // facebook::thrift::concurrency
 
 using namespace facebook::thrift::concurrency::test;