summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-11 20:20:25 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-11 21:34:08 +0100
commit42b016dc96472993fa19f8283c65dcd3f447f124 (patch)
tree616b1e151a87b5831e68c76891739bfcd0fa2cb8
parentC++17 (diff)
downloadlibadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.tar.bz2
libadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.tar.xz
libadhocutil-42b016dc96472993fa19f8283c65dcd3f447f124.zip
Tidy threading code... no need for pointers now
-rw-r--r--libadhocutil/unittests/testResourcePool.cpp13
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());