diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 13:13:47 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 13:13:47 +0100 |
commit | f8ee56f6dc8cf7e92c4bfc5930d32b14f634141c (patch) | |
tree | 909ac21da2cd351a98022105bb7c76bc41259a76 /test | |
parent | Simplify doWork, add tests for various interface uses (diff) | |
download | ilt-f8ee56f6dc8cf7e92c4bfc5930d32b14f634141c.tar.bz2 ilt-f8ee56f6dc8cf7e92c4bfc5930d32b14f634141c.tar.xz ilt-f8ee56f6dc8cf7e92c4bfc5930d32b14f634141c.zip |
Current thread partakes in work effort while waiting
This will prevent deadlock if the work pool is otherwise busy by ensuring work is always being done
Diffstat (limited to 'test')
-rw-r--r-- | test/test-worker.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test-worker.cpp b/test/test-worker.cpp index 319261b..76b7138 100644 --- a/test/test-worker.cpp +++ b/test/test-worker.cpp @@ -81,3 +81,24 @@ BOOST_AUTO_TEST_CASE(lambda_value) 1, 2) ->get()); } + +BOOST_AUTO_TEST_CASE(recursive, *boost::unit_test::timeout(5)) +{ + auto recurse = []() { + std::vector<Worker::WorkPtrT<uint32_t>> ps; + for (int i {}; i < 30; ++i) { + ps.push_back(Worker::addWork(workCounter)); + } + return std::accumulate(ps.begin(), ps.end(), 0U, [](auto && out, auto && p) { + return out += p->get(); + }); + }; + std::vector<Worker::WorkPtrT<uint32_t>> ps; + for (int i {}; i < 30; ++i) { + ps.push_back(Worker::addWork(recurse)); + } + std::set<uint32_t> out; + std::transform(ps.begin(), ps.end(), std::inserter(out, out.end()), [](auto && p) { + return p->get(); + }); +} |