Merge branch 'master' into scmaster
[nova-tt.git] / testsuite / thread_pool_test.cpp
blob2d9357f2cffa2eb11ea9e155e43359867b0c771e
1 #define BOOST_TEST_MAIN
2 #include <boost/test/included/unit_test.hpp>
4 #include <atomic>
6 #include "thread_pool.hpp"
8 BOOST_AUTO_TEST_CASE( int_test )
10 std::atomic_int count(0);
13 nova::thread_pool pool(4);
15 for (int i = 0; i != 100; ++i) {
16 pool.schedule([&]() {
17 count += 1;
18 });
22 BOOST_REQUIRE_EQUAL( count, 100 );
25 BOOST_AUTO_TEST_CASE( future_test )
27 std::future<int> answer;
30 nova::thread_pool pool(4);
32 answer = pool.schedule([]() {
33 return 42;
34 });
37 BOOST_REQUIRE_EQUAL( answer.get(), 42 );