Merge pull request #9761 from ClickHouse/remove-unused-code-thread-pool

Remove unused (obsolete) code from ThreadPool
This commit is contained in:
alexey-milovidov 2020-03-22 06:34:40 +03:00 committed by GitHub
commit 2fd4439e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 45 deletions

View File

@ -270,36 +270,6 @@ template class ThreadPoolImpl<std::thread>;
template class ThreadPoolImpl<ThreadFromGlobalPool>;
void ExceptionHandler::setException(std::exception_ptr exception)
{
std::unique_lock lock(mutex);
if (!first_exception)
first_exception = std::move(exception); // NOLINT
}
void ExceptionHandler::throwIfException()
{
std::unique_lock lock(mutex);
if (first_exception)
std::rethrow_exception(first_exception);
}
ThreadPool::Job createExceptionHandledJob(ThreadPool::Job job, ExceptionHandler & handler)
{
return [job{std::move(job)}, &handler] ()
{
try
{
job();
}
catch (...)
{
handler.setException(std::current_exception());
}
};
}
GlobalThreadPool & GlobalThreadPool::instance()
{
static GlobalThreadPool ret;

View File

@ -216,18 +216,3 @@ private:
/// Recommended thread pool for the case when multiple thread pools are created and destroyed.
using ThreadPool = ThreadPoolImpl<ThreadFromGlobalPool>;
/// Allows to save first catched exception in jobs and postpone its rethrow.
class ExceptionHandler
{
public:
void setException(std::exception_ptr exception);
void throwIfException();
private:
std::exception_ptr first_exception;
std::mutex mutex;
};
ThreadPool::Job createExceptionHandledJob(ThreadPool::Job job, ExceptionHandler & handler);