From 03dedd9bd5125358d6fb21cff1b059cfe53fc984 Mon Sep 17 00:00:00 2001 From: Marc Slemko Date: Thu, 20 Jul 2006 00:58:47 +0000 Subject: [PATCH] Fixed a few problems found on linux x86_64 version git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664728 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/concurrency/ThreadManager.cc | 6 ++---- lib/cpp/src/concurrency/Util.h | 1 + lib/cpp/src/concurrency/test/Tests.cc | 6 ++++-- lib/cpp/src/concurrency/test/ThreadFactoryTests.h | 12 ++++++------ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/cpp/src/concurrency/ThreadManager.cc b/lib/cpp/src/concurrency/ThreadManager.cc index 69a96ff8..0aa4bef4 100644 --- a/lib/cpp/src/concurrency/ThreadManager.cc +++ b/lib/cpp/src/concurrency/ThreadManager.cc @@ -164,7 +164,7 @@ class ThreadManager::Worker: public Runnable { _manager->_workerCount++; - _manager->_monitor.notify(); + _manager->_monitor.notifyAll(); } do { @@ -358,10 +358,8 @@ void ThreadManager::Impl::add(Runnable* value) { /* 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(); } } diff --git a/lib/cpp/src/concurrency/Util.h b/lib/cpp/src/concurrency/Util.h index d04435d5..8467a2cb 100644 --- a/lib/cpp/src/concurrency/Util.h +++ b/lib/cpp/src/concurrency/Util.h @@ -2,6 +2,7 @@ #define _concurrency_Util_h_ 1 #include +#include #include namespace facebook { namespace thrift { namespace concurrency { diff --git a/lib/cpp/src/concurrency/test/Tests.cc b/lib/cpp/src/concurrency/test/Tests.cc index 02e1724d..d139f55c 100644 --- a/lib/cpp/src/concurrency/test/Tests.cc +++ b/lib/cpp/src/concurrency/test/Tests.cc @@ -30,9 +30,11 @@ int main(int argc, char** argv) { 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; diff --git a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h index 0d935648..1e0b1393 100644 --- a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +++ b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h @@ -83,7 +83,7 @@ public: int& _count; }; - bool reapNThreads(int count=100) { + bool reapNThreads(int count=10) { Monitor* monitor = new Monitor(); @@ -127,11 +127,11 @@ public: public: enum STATE { - UNINITIALIZED = 1000, - STARTING = 1001, - STARTED = 1002, - STOPPING = 1003, - STOPPED = 1004 + UNINITIALIZED, + STARTING, + STARTED, + STOPPING, + STOPPED }; SynchStartTask(Monitor& monitor, -- 2.17.1