_manager->_workerCount++;
- _manager->_monitor.notify();
+ _manager->_monitor.notifyAll();
}
do {
/* If queue was empty notify a thread, otherwise all worker threads are running and will get around to this
task in time. */
- if(isEmpty) {
+ if(isEmpty && _idleCount > 0) {
- assert(_idleCount == _workerCount);
-
_monitor.notify();
}
}
#define _concurrency_Util_h_ 1
#include <assert.h>
+#include <stddef.h>
#include <sys/time.h>
namespace facebook { namespace thrift { namespace concurrency {
assert(threadFactoryTests.helloWorldTest());
- std::cout << "\t\tThreadFactory reap N threads test: N = 100" << std::endl;
+ size_t count = 10000;
- assert(threadFactoryTests.reapNThreads(100));
+ std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl;
+
+ assert(threadFactoryTests.reapNThreads(count));
std::cout << "\t\tThreadFactory synchrous start test" << std::endl;
int& _count;
};
- bool reapNThreads(int count=100) {
+ bool reapNThreads(int count=10) {
Monitor* monitor = new Monitor();
public:
enum STATE {
- UNINITIALIZED = 1000,
- STARTING = 1001,
- STARTED = 1002,
- STOPPING = 1003,
- STOPPED = 1004
+ UNINITIALIZED,
+ STARTING,
+ STARTED,
+ STOPPING,
+ STOPPED
};
SynchStartTask(Monitor& monitor,