More test code added...
more bugs found
facebook::thrift::concurrency::ThreadManager::add
Fixed dispatch error that resulted in only one of N worker threads ever getting notified of work
facebook::thrift::concurrency::ThreadManager
Cleaned up addWorker/removeWorker and stop logic so that adding/removing workers doesn't wake up
all blocked workers.
facebook::thrift::concurrency::Thread
facebook::thrift::concurrency::Runnable
Fixed initialization logic so that runnable can return the thread that runs it
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664729 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/ThreadManager.h b/lib/cpp/src/concurrency/ThreadManager.h
index 596471d..aa5a98a 100644
--- a/lib/cpp/src/concurrency/ThreadManager.h
+++ b/lib/cpp/src/concurrency/ThreadManager.h
@@ -32,6 +32,26 @@
virtual ~ThreadManager() {}
+ /** Starts the thread manager. Verifies all attributes have been properly initialized, then allocates necessary resources to begin operation */
+
+ virtual void start() = 0;
+
+ /** Stops the thread manager. Aborts all remaining unprocessed task, shuts down all created worker threads, and realeases all allocated resources.
+ This method blocks for all worker threads to complete, thus it can potentially block forever if a worker thread is running a task that
+ won't terminate. */
+
+ virtual void stop() = 0;
+
+ enum STATE {
+ UNINITIALIZED,
+ STARTING,
+ STARTED,
+ STOPPING,
+ STOPPED
+ };
+
+ virtual const STATE state() const = 0;
+
virtual const ThreadFactory* threadFactory() const = 0;
virtual void threadFactory(const ThreadFactory* value) = 0;