From 42b016dc96472993fa19f8283c65dcd3f447f124 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 11 Apr 2018 20:20:25 +0100 Subject: C++17 Tidy threading code... no need for pointers now --- libadhocutil/unittests/testResourcePool.cpp | 13 ++++++------- 1 file 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 threads; + std::list 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()); -- cgit v1.2.3