diff options
Diffstat (limited to 'lib/cpp/test')
-rw-r--r-- | lib/cpp/test/CMakeLists.txt | 5 | ||||
-rwxr-xr-x | lib/cpp/test/Makefile.am | 4 | ||||
-rw-r--r-- | lib/cpp/test/TNonblockingSSLServerTest.cpp | 7 | ||||
-rw-r--r-- | lib/cpp/test/TNonblockingServerTest.cpp | 9 | ||||
-rw-r--r-- | lib/cpp/test/TServerIntegrationTest.cpp | 8 | ||||
-rw-r--r-- | lib/cpp/test/TransportTest.cpp | 2 | ||||
-rw-r--r-- | lib/cpp/test/concurrency/MutexTest.cpp | 123 | ||||
-rw-r--r-- | lib/cpp/test/concurrency/RWMutexStarveTest.cpp | 157 | ||||
-rw-r--r-- | lib/cpp/test/concurrency/ThreadFactoryTests.h | 10 | ||||
-rw-r--r-- | lib/cpp/test/concurrency/ThreadManagerTests.h | 59 | ||||
-rw-r--r-- | lib/cpp/test/concurrency/TimerManagerTests.h | 12 | ||||
-rw-r--r-- | lib/cpp/test/processor/ProcessorTest.cpp | 6 | ||||
-rw-r--r-- | lib/cpp/test/processor/ServerThread.cpp | 4 |
13 files changed, 31 insertions, 375 deletions
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index b30ef1780..8a8aadad1 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -84,11 +84,6 @@ set(UnitTest_SOURCES TServerTransportTest.cpp ) -if(NOT WITH_STDTHREADS AND NOT MSVC AND NOT MINGW) - list(APPEND UnitTest_SOURCES concurrency/MutexTest.cpp) - list(APPEND UnitTest_SOURCES concurrency/RWMutexStarveTest.cpp) -endif() - add_executable(UnitTests ${UnitTest_SOURCES}) target_link_libraries(UnitTests testgencpp ${Boost_LIBRARIES}) LINK_AGAINST_THRIFT_LIBRARY(UnitTests thrift) diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am index d645a6501..5bb9eb760 100755 --- a/lib/cpp/test/Makefile.am +++ b/lib/cpp/test/Makefile.am @@ -135,10 +135,6 @@ UnitTests_SOURCES = \ TServerTransportTest.cpp \ TTransportCheckThrow.h -UnitTests_SOURCES += \ - concurrency/MutexTest.cpp \ - concurrency/RWMutexStarveTest.cpp - UnitTests_LDADD = \ libtestgencpp.la \ $(BOOST_TEST_LDADD) \ diff --git a/lib/cpp/test/TNonblockingSSLServerTest.cpp b/lib/cpp/test/TNonblockingSSLServerTest.cpp index 330380b34..2111de8b0 100644 --- a/lib/cpp/test/TNonblockingSSLServerTest.cpp +++ b/lib/cpp/test/TNonblockingSSLServerTest.cpp @@ -218,12 +218,7 @@ protected: runner->userEventBase = userEventBase_; std::unique_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory( - new apache::thrift::concurrency::PlatformThreadFactory( -#if !USE_STD_THREAD - concurrency::PlatformThreadFactory::OTHER, concurrency::PlatformThreadFactory::NORMAL, - 1, -#endif - false)); + new apache::thrift::concurrency::ThreadFactory(false)); thread = threadFactory->newThread(runner); thread->start(); runner->readyBarrier(); diff --git a/lib/cpp/test/TNonblockingServerTest.cpp b/lib/cpp/test/TNonblockingServerTest.cpp index f0bb283ff..f2f592203 100644 --- a/lib/cpp/test/TNonblockingServerTest.cpp +++ b/lib/cpp/test/TNonblockingServerTest.cpp @@ -33,7 +33,7 @@ using apache::thrift::concurrency::Guard; using apache::thrift::concurrency::Monitor; using apache::thrift::concurrency::Mutex; -using apache::thrift::concurrency::PlatformThreadFactory; +using apache::thrift::concurrency::ThreadFactory; using apache::thrift::concurrency::Runnable; using apache::thrift::concurrency::Thread; using apache::thrift::concurrency::ThreadFactory; @@ -147,12 +147,7 @@ protected: runner->userEventBase = userEventBase_; shared_ptr<ThreadFactory> threadFactory( - new PlatformThreadFactory( -#if !USE_STD_THREAD - PlatformThreadFactory::OTHER, PlatformThreadFactory::NORMAL, - 1, -#endif - false)); + new ThreadFactory(false)); thread = threadFactory->newThread(runner); thread->start(); runner->readyBarrier(); diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp index 7976c8bcf..a7680d89e 100644 --- a/lib/cpp/test/TServerIntegrationTest.cpp +++ b/lib/cpp/test/TServerIntegrationTest.cpp @@ -379,7 +379,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( shared_ptr<apache::thrift::concurrency::ThreadFactory>( - new apache::thrift::concurrency::PlatformThreadFactory)); + new apache::thrift::concurrency::ThreadFactory)); pServer->getThreadManager()->start(); // thread factory has 4 threads as a default @@ -394,7 +394,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( shared_ptr<apache::thrift::concurrency::ThreadFactory>( - new apache::thrift::concurrency::PlatformThreadFactory)); + new apache::thrift::concurrency::ThreadFactory)); pServer->getThreadManager()->start(); // thread factory has 4 threads as a default @@ -409,7 +409,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( shared_ptr<apache::thrift::concurrency::ThreadFactory>( - new apache::thrift::concurrency::PlatformThreadFactory)); + new apache::thrift::concurrency::ThreadFactory)); pServer->getThreadManager()->start(); pServer->setConcurrentClientLimit(4); @@ -420,7 +420,7 @@ BOOST_FIXTURE_TEST_CASE(test_threadpool_stress, TServerIntegrationProcessorTestFixture<TThreadPoolServer>) { pServer->getThreadManager()->threadFactory( shared_ptr<apache::thrift::concurrency::ThreadFactory>( - new apache::thrift::concurrency::PlatformThreadFactory)); + new apache::thrift::concurrency::ThreadFactory)); pServer->getThreadManager()->start(); stress(10, boost::posix_time::seconds(3)); diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp index ce1954469..387207142 100644 --- a/lib/cpp/test/TransportTest.cpp +++ b/lib/cpp/test/TransportTest.cpp @@ -1031,7 +1031,7 @@ struct global_fixture { apache::thrift::transport::TWinsockSingleton::create(); #endif - apache::thrift::concurrency::PlatformThreadFactory factory; + apache::thrift::concurrency::ThreadFactory factory; factory.setDetached(false); alarmThread_ = factory.newThread( diff --git a/lib/cpp/test/concurrency/MutexTest.cpp b/lib/cpp/test/concurrency/MutexTest.cpp deleted file mode 100644 index 781ec1a40..000000000 --- a/lib/cpp/test/concurrency/MutexTest.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// This is linked into the UnitTests test executable - -#include <boost/test/unit_test.hpp> - -#include "thrift/concurrency/Exception.h" -#include "thrift/concurrency/Mutex.h" - -using boost::unit_test::test_suite; -using boost::unit_test::framework::master_test_suite; - -using namespace apache::thrift::concurrency; - -struct LFAT -{ - LFAT() - : uut(Mutex::ERRORCHECK_INITIALIZER) - { - BOOST_CHECK_EQUAL(0, pthread_mutex_init(&mx, 0)); - BOOST_CHECK_EQUAL(0, pthread_cond_init(&cv, 0)); - } - - Mutex uut; - pthread_mutex_t mx; - pthread_cond_t cv; -}; - -// Helper for testing mutex behavior when locked by another thread -void * lockFromAnotherThread(void *ptr) -{ - struct LFAT *lfat = (LFAT *)ptr; - BOOST_CHECK_EQUAL (0, pthread_mutex_lock(&lfat->mx)); // synchronize with testing thread - BOOST_CHECK_NO_THROW( lfat->uut.lock()); - BOOST_CHECK_EQUAL (0, pthread_cond_signal(&lfat->cv)); // tell testing thread we have locked the mutex - BOOST_CHECK_EQUAL (0, pthread_cond_wait(&lfat->cv, &lfat->mx)); // wait for testing thread to signal condition variable telling us to unlock - BOOST_CHECK_NO_THROW( lfat->uut.unlock()); - return ptr; // testing thread should join to ensure completeness -} - -BOOST_AUTO_TEST_SUITE(MutexTest) - -BOOST_AUTO_TEST_CASE(happy_path) -{ - Mutex uut(Mutex::ERRORCHECK_INITIALIZER); // needed to test unlocking twice without undefined behavior - - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_THROW ( uut.lock(), SystemResourceException); // EDEADLK (this thread owns it) - BOOST_CHECK_NO_THROW( uut.unlock()); -} - -BOOST_AUTO_TEST_CASE(recursive_happy_path) -{ - Mutex uut(Mutex::RECURSIVE_INITIALIZER); - - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_NO_THROW( uut.unlock()); - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_NO_THROW( uut.unlock()); - BOOST_CHECK_NO_THROW( uut.lock()); - BOOST_CHECK_NO_THROW( uut.unlock()); - BOOST_CHECK_NO_THROW( uut.unlock()); - BOOST_CHECK_NO_THROW( uut.unlock()); -} - -BOOST_AUTO_TEST_CASE(trylock) -{ - Mutex uut(Mutex::ADAPTIVE_INITIALIZER); // just using another initializer for coverage - - BOOST_CHECK ( uut.trylock()); - BOOST_CHECK (!uut.trylock()); - BOOST_CHECK_NO_THROW( uut.unlock()); -} - -BOOST_AUTO_TEST_CASE(timedlock) -{ - pthread_t th; - struct LFAT lfat; - - BOOST_CHECK ( lfat.uut.timedlock(100)); - BOOST_CHECK_THROW ( lfat.uut.timedlock(100), - SystemResourceException); // EDEADLK (current thread owns mutex - logic error) - BOOST_CHECK_NO_THROW( lfat.uut.unlock()); - - BOOST_CHECK_EQUAL (0, pthread_mutex_lock(&lfat.mx)); // synchronize with helper thread - BOOST_CHECK_EQUAL (0, pthread_create(&th, NULL, - lockFromAnotherThread, &lfat)); // create helper thread - BOOST_CHECK_EQUAL (0, pthread_cond_wait(&lfat.cv, &lfat.mx)); // wait for helper thread to lock mutex - - BOOST_CHECK (!lfat.uut.timedlock(100)); // false: another thread owns the lock - - BOOST_CHECK_EQUAL (0, pthread_cond_signal(&lfat.cv)); // tell helper thread we are done - BOOST_CHECK_EQUAL (0, pthread_mutex_unlock(&lfat.mx)); // let helper thread clean up - BOOST_CHECK_EQUAL (0, pthread_join(th, 0)); // wait for testing thread to unlock and be done -} - -BOOST_AUTO_TEST_CASE(underlying) -{ - Mutex uut; - - BOOST_CHECK ( uut.getUnderlyingImpl()); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/lib/cpp/test/concurrency/RWMutexStarveTest.cpp b/lib/cpp/test/concurrency/RWMutexStarveTest.cpp deleted file mode 100644 index 985a230a0..000000000 --- a/lib/cpp/test/concurrency/RWMutexStarveTest.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// This is linked into the UnitTests test executable - -#include <boost/test/unit_test.hpp> - -#include "thrift/concurrency/Mutex.h" -#include "thrift/concurrency/PosixThreadFactory.h" -#include <memory> - -using std::shared_ptr; -using boost::unit_test::test_suite; -using boost::unit_test::framework::master_test_suite; - -using namespace apache::thrift::concurrency; - -class Locker : public Runnable { -protected: - Locker(shared_ptr<ReadWriteMutex> rwlock, bool writer) - : rwlock_(rwlock), writer_(writer), started_(false), gotLock_(false), signaled_(false) {} - -public: - virtual void run() { - started_ = true; - if (writer_) { - rwlock_->acquireWrite(); - } else { - rwlock_->acquireRead(); - } - gotLock_ = true; - while (!signaled_) { - usleep(5000); - } - rwlock_->release(); - } - - bool started() const { return started_; } - bool gotLock() const { return gotLock_; } - void signal() { signaled_ = true; } - -protected: - shared_ptr<ReadWriteMutex> rwlock_; - bool writer_; - volatile bool started_; - volatile bool gotLock_; - volatile bool signaled_; -}; - -class Reader : public Locker { -public: - Reader(shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, false) {} -}; - -class Writer : public Locker { -public: - Writer(shared_ptr<ReadWriteMutex> rwlock) : Locker(rwlock, true) {} -}; - -void test_starve(PosixThreadFactory::POLICY policy) { - // the man pages for pthread_wrlock_rdlock suggest that any OS guarantee about - // writer starvation may be influenced by the scheduling policy, so let's try - // all 3 policies to see if any of them work. - PosixThreadFactory factory(policy); - factory.setDetached(false); - - shared_ptr<ReadWriteMutex> rwlock(new NoStarveReadWriteMutex()); - - shared_ptr<Reader> reader1(new Reader(rwlock)); - shared_ptr<Reader> reader2(new Reader(rwlock)); - shared_ptr<Writer> writer(new Writer(rwlock)); - - shared_ptr<Thread> treader1 = factory.newThread(reader1); - shared_ptr<Thread> treader2 = factory.newThread(reader2); - shared_ptr<Thread> twriter = factory.newThread(writer); - - // launch a reader and make sure he has the lock - treader1->start(); - while (!reader1->gotLock()) { - usleep(2000); - } - - // launch a writer and make sure he's blocked on the lock - twriter->start(); - while (!writer->started()) { - usleep(2000); - } - // tricky part... we can never be 100% sure that the writer is actually - // blocked on the lock, but we can pretty reasonably sure because we know - // he just executed the line immediately before getting the lock, and - // we'll wait a full second for him to get on it. - sleep(1); - - // launch a second reader... if the RWMutex guarantees that writers won't - // starve, this reader should not be able to acquire the lock until the writer - // has acquired and released it. - treader2->start(); - while (!reader2->started()) { - usleep(2000); - } - // again... can't be 100% sure the reader is waiting on (or has) the lock - // but we can be close. - sleep(1); - - // tell reader 1 to let go of the lock - reader1->signal(); - - // wait for someone to get the lock - while (!reader2->gotLock() && !writer->gotLock()) { - usleep(2000); - } - - // the test succeeded if the WRITER got the lock. - bool success = writer->gotLock(); - - // tell everyone we're done and wait for them to finish - reader2->signal(); - writer->signal(); - treader1->join(); - treader2->join(); - twriter->join(); - - // make sure it worked. - BOOST_CHECK_MESSAGE(success, "writer is starving"); -} - -BOOST_AUTO_TEST_SUITE(RWMutexStarveTest) - -BOOST_AUTO_TEST_CASE(test_starve_other) { - test_starve(PosixThreadFactory::OTHER); -} - -BOOST_AUTO_TEST_CASE(test_starve_rr) { - test_starve(PosixThreadFactory::ROUND_ROBIN); -} - -BOOST_AUTO_TEST_CASE(test_starve_fifo) { - test_starve(PosixThreadFactory::FIFO); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h index ba9850286..8ab754c89 100644 --- a/lib/cpp/test/concurrency/ThreadFactoryTests.h +++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h @@ -19,7 +19,7 @@ #include <thrift/thrift-config.h> #include <thrift/concurrency/Thread.h> -#include <thrift/concurrency/PlatformThreadFactory.h> +#include <thrift/concurrency/ThreadFactory.h> #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Mutex.h> #include <thrift/concurrency/Util.h> @@ -66,7 +66,7 @@ public: bool reapNThreads(int loop = 1, int count = 10) { - PlatformThreadFactory threadFactory = PlatformThreadFactory(); + ThreadFactory threadFactory = ThreadFactory(); shared_ptr<Monitor> monitor(new Monitor); for (int lix = 0; lix < loop; lix++) { @@ -159,7 +159,7 @@ public: shared_ptr<SynchStartTask> task = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state)); - PlatformThreadFactory threadFactory = PlatformThreadFactory(); + ThreadFactory threadFactory = ThreadFactory(); shared_ptr<Thread> thread = threadFactory.newThread(task); @@ -265,7 +265,7 @@ public: Monitor& _mon; }; - void foo(PlatformThreadFactory* tf) { (void)tf; } + void foo(ThreadFactory* tf) { (void)tf; } bool floodNTest(size_t loop = 1, size_t count = 100000) { @@ -274,7 +274,7 @@ public: for (size_t lix = 0; lix < loop; lix++) { - PlatformThreadFactory threadFactory = PlatformThreadFactory(); + ThreadFactory threadFactory = ThreadFactory(); threadFactory.setDetached(true); for (size_t tix = 0; tix < count; tix++) { 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(); diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h index 1c52c470b..c15b14b80 100644 --- a/lib/cpp/test/concurrency/TimerManagerTests.h +++ b/lib/cpp/test/concurrency/TimerManagerTests.h @@ -18,7 +18,7 @@ */ #include <thrift/concurrency/TimerManager.h> -#include <thrift/concurrency/PlatformThreadFactory.h> +#include <thrift/concurrency/ThreadFactory.h> #include <thrift/concurrency/Monitor.h> #include <thrift/concurrency/Util.h> @@ -80,7 +80,7 @@ public: { TimerManager timerManager; - timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory())); timerManager.start(); if (timerManager.state() != TimerManager::STARTED) { std::cerr << "timerManager is not in the STARTED state, but should be" << std::endl; @@ -125,7 +125,7 @@ public: */ bool test01(int64_t timeout = 1000LL) { TimerManager timerManager; - timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory())); timerManager.start(); assert(timerManager.state() == TimerManager::STARTED); @@ -158,7 +158,7 @@ public: */ bool test02(int64_t timeout = 1000LL) { TimerManager timerManager; - timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory())); timerManager.start(); assert(timerManager.state() == TimerManager::STARTED); @@ -191,7 +191,7 @@ public: */ bool test03(int64_t timeout = 1000LL) { TimerManager timerManager; - timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory())); timerManager.start(); assert(timerManager.state() == TimerManager::STARTED); @@ -228,7 +228,7 @@ public: */ bool test04(int64_t timeout = 1000LL) { TimerManager timerManager; - timerManager.threadFactory(shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory())); + timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory())); timerManager.start(); assert(timerManager.state() == TimerManager::STARTED); diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp index 36ce01311..9483a0e91 100644 --- a/lib/cpp/test/processor/ProcessorTest.cpp +++ b/lib/cpp/test/processor/ProcessorTest.cpp @@ -25,7 +25,7 @@ #include <boost/test/unit_test.hpp> -#include <thrift/concurrency/PlatformThreadFactory.h> +#include <thrift/concurrency/ThreadFactory.h> #include <thrift/concurrency/Monitor.h> #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/server/TThreadedServer.h> @@ -94,7 +94,7 @@ public: const std::shared_ptr<TProtocolFactory>& protocolFactory) { std::shared_ptr<TServerSocket> socket(new TServerSocket(port)); - std::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); + std::shared_ptr<ThreadFactory> threadFactory(new ThreadFactory); std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); threadManager->threadFactory(threadFactory); threadManager->start(); @@ -123,7 +123,7 @@ public: } std::shared_ptr<TNonblockingServerSocket> socket(new TNonblockingServerSocket(port)); - std::shared_ptr<PlatformThreadFactory> threadFactory(new PlatformThreadFactory); + std::shared_ptr<ThreadFactory> threadFactory(new ThreadFactory); std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(8); threadManager->threadFactory(threadFactory); threadManager->start(); diff --git a/lib/cpp/test/processor/ServerThread.cpp b/lib/cpp/test/processor/ServerThread.cpp index 4d1ec4c1d..b0505005b 100644 --- a/lib/cpp/test/processor/ServerThread.cpp +++ b/lib/cpp/test/processor/ServerThread.cpp @@ -21,7 +21,7 @@ #include "ServerThread.h" -#include <thrift/concurrency/PlatformThreadFactory.h> +#include <thrift/concurrency/ThreadFactory.h> #include <thrift/concurrency/ThreadManager.h> #include <thrift/server/TThreadPoolServer.h> #include <thrift/transport/TBufferTransports.h> @@ -38,7 +38,7 @@ void ServerThread::start() { helper_.reset(new Helper(this)); // Start the other thread - concurrency::PlatformThreadFactory threadFactory; + concurrency::ThreadFactory threadFactory; threadFactory.setDetached(false); thread_ = threadFactory.newThread(helper_); |