mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
34 lines
580 B
C++
34 lines
580 B
C++
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <Common/ThreadPool.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
static bool check()
|
|
{
|
|
ThreadPool pool(10);
|
|
|
|
pool.scheduleOrThrowOnError([] { throw std::runtime_error("Hello, world!"); });
|
|
|
|
try
|
|
{
|
|
for (size_t i = 0; i < 500; ++i)
|
|
pool.scheduleOrThrowOnError([] {}); /// An exception will be rethrown from this method.
|
|
}
|
|
catch (const std::runtime_error &)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
pool.wait();
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
TEST(ThreadPool, ExceptionFromSchedule)
|
|
{
|
|
EXPECT_TRUE(check());
|
|
}
|