diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-11 20:20:25 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-11 21:34:08 +0100 |
commit | 42b016dc96472993fa19f8283c65dcd3f447f124 (patch) | |
tree | 616b1e151a87b5831e68c76891739bfcd0fa2cb8 | |
parent | C++17 (diff) | |
download | libadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.tar.bz2 libadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.tar.xz libadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.zip |
C++17libadhocutil-0.5.0
Tidy threading code... no need for pointers now
-rw-r--r-- | libadhocutil/unittests/testResourcePool.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libadhocutil/unittests/testResourcePool.cpp b/libadhocutil/unittests/testResourcePool.cpp index 216c40c..ddbd57b 100644 --- a/libadhocutil/unittests/testResourcePool.cpp +++ b/libadhocutil/unittests/testResourcePool.cpp @@ -238,22 +238,21 @@ BOOST_AUTO_TEST_CASE( idle ) BOOST_REQUIRE_EQUAL(0, MockResource::count); } -BOOST_AUTO_TEST_CASE( threading1 ) +BOOST_AUTO_TEST_CASE( threading1, * boost::unit_test::timeout(10) ) { TRPSmall pool; - std::list<std::thread *> threads; + std::list<std::thread> threads; for (int x = 0; x < 100; x += 1) { - threads.push_back(new std::thread([&pool](){ + threads.emplace_back([&pool](){ auto r = pool.get(); usleep(50000); - })); + }); usleep(5000); // pool size never exceeds 3 BOOST_REQUIRE_LE(pool.inUseCount(), 3); } - for(std::thread * thread : threads) { - thread->join(); - delete thread; + for(auto & thread : threads) { + thread.join(); } // pool keep returns to 1 BOOST_REQUIRE_EQUAL(1, pool.availableCount()); |