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/PosixThreadFactory.cc b/lib/cpp/src/concurrency/PosixThreadFactory.cc
index 3587c03..00b2613 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.cc
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.cc
@@ -36,9 +36,6 @@
int _stackSize;
- Runnable* _runnable;
-
-
public:
PthreadThread(int policy, int priority, int stackSize, Runnable* runnable) :
@@ -46,9 +43,10 @@
_state(uninitialized),
_policy(policy),
_priority(priority),
- _stackSize(stackSize),
- _runnable(runnable)
- {}
+ _stackSize(stackSize) {
+
+ this->Thread::runnable(runnable);
+ }
void start() {
@@ -92,7 +90,9 @@
}
}
- Runnable* runnable() const {return _runnable;}
+ Runnable* runnable() const {return Thread::runnable();}
+
+ void runnable(Runnable* value) {Thread::runnable(value);}
};
@@ -107,7 +107,7 @@
thread->_state = starting;
- thread->_runnable->run();
+ thread->runnable()->run();
if(thread->_state != stopping && thread->_state != stopped) {
thread->_state = stopping;