summaryrefslogtreecommitdiff
path: root/lib/cpp/test/concurrency/ThreadManagerTests.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cpp/test/concurrency/ThreadManagerTests.h')
-rw-r--r--lib/cpp/test/concurrency/ThreadManagerTests.h59
1 files changed, 7 insertions, 52 deletions
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
index d6c092d6c..b3a319a57 100644
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -19,7 +19,7 @@
#include <thrift/thrift-config.h>
#include <thrift/concurrency/ThreadManager.h>
-#include <thrift/concurrency/PlatformThreadFactory.h>
+#include <thrift/concurrency/ThreadFactory.h>
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/Util.h>
@@ -108,12 +108,9 @@ public:
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
- shared_ptr<PlatformThreadFactory> threadFactory
- = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory(false));
+ shared_ptr<ThreadFactory> threadFactory
+ = shared_ptr<ThreadFactory>(new ThreadFactory(false));
-#if !USE_STD_THREAD
- threadFactory->setPriority(PosixThreadFactory::HIGHEST);
-#endif
threadManager->threadFactory(threadFactory);
threadManager->start();
@@ -257,12 +254,9 @@ public:
shared_ptr<ThreadManager> threadManager
= ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
- shared_ptr<PlatformThreadFactory> threadFactory
- = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+ shared_ptr<ThreadFactory> threadFactory
+ = shared_ptr<ThreadFactory>(new ThreadFactory());
-#if !USE_STD_THREAD
- threadFactory->setPriority(PosixThreadFactory::HIGHEST);
-#endif
threadManager->threadFactory(threadFactory);
threadManager->start();
@@ -401,54 +395,15 @@ public:
return false;
}
-#if !USE_STD_THREAD
- // test once with a detached thread factory and once with a joinable thread factory
-
- shared_ptr<PosixThreadFactory> threadFactory
- = shared_ptr<PosixThreadFactory>(new PosixThreadFactory(false));
-
- std::cout << "\t\t\tapiTest with joinable thread factory" << std::endl;
- if (!apiTestWithThreadFactory(threadFactory)) {
- return false;
- }
-
- threadFactory.reset(new PosixThreadFactory(true));
- std::cout << "\t\t\tapiTest with detached thread factory" << std::endl;
- return apiTestWithThreadFactory(threadFactory);
-#else
- return apiTestWithThreadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory()));
-#endif
+ return apiTestWithThreadFactory(shared_ptr<ThreadFactory>(new ThreadFactory()));
}
- bool apiTestWithThreadFactory(shared_ptr<PlatformThreadFactory> threadFactory)
+ bool apiTestWithThreadFactory(shared_ptr<ThreadFactory> threadFactory)
{
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(1);
threadManager->threadFactory(threadFactory);
-#if !USE_STD_THREAD
- threadFactory->setPriority(PosixThreadFactory::HIGHEST);
-
- // verify we cannot change the thread factory to one with the opposite detached setting
- shared_ptr<PlatformThreadFactory> threadFactory2
- = shared_ptr<PosixThreadFactory>(new PlatformThreadFactory(
- PosixThreadFactory::ROUND_ROBIN,
- PosixThreadFactory::NORMAL,
- 1,
- !threadFactory->isDetached()));
- try {
- threadManager->threadFactory(threadFactory2);
- // if the call succeeded we changed the thread factory to one that had the opposite setting for "isDetached()".
- // this is bad, because the thread manager checks with the thread factory to see if it should join threads
- // as they are leaving - so the detached status of new threads cannot change while there are existing threads.
- std::cerr << "\t\t\tShould not be able to change thread factory detached disposition" << std::endl;
- return false;
- }
- catch (InvalidArgumentException& ex) {
- /* expected */
- }
-#endif
-
std::cout << "\t\t\t\tstarting.. " << std::endl;
threadManager->start();