1#include <iostream>
2#include <stdexcept>
3#include <Common/ThreadPool.h>
4
5#include <gtest/gtest.h>
6
7
8static bool check()
9{
10 ThreadPool pool(10);
11
12 pool.scheduleOrThrowOnError([] { throw std::runtime_error("Hello, world!"); });
13
14 try
15 {
16 for (size_t i = 0; i < 100; ++i)
17 pool.scheduleOrThrowOnError([] {}); /// An exception will be rethrown from this method.
18 }
19 catch (const std::runtime_error &)
20 {
21 return true;
22 }
23
24 pool.wait();
25
26 return false;
27}
28
29
30TEST(ThreadPool, ExceptionFromSchedule)
31{
32 EXPECT_TRUE(check());
33}
34