From 64a45e32d862adbe86577cfd85cb82baf212eff3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 19 Mar 2020 21:45:28 +0300 Subject: [PATCH] Remove unused (obsolete) code from ThreadPool #9154 --- dbms/src/Common/ThreadPool.cpp | 30 ------------------------------ dbms/src/Common/ThreadPool.h | 15 --------------- 2 files changed, 45 deletions(-) diff --git a/dbms/src/Common/ThreadPool.cpp b/dbms/src/Common/ThreadPool.cpp index 2b57ee5dbb6..7d6935c0383 100644 --- a/dbms/src/Common/ThreadPool.cpp +++ b/dbms/src/Common/ThreadPool.cpp @@ -270,36 +270,6 @@ template class ThreadPoolImpl; template class ThreadPoolImpl; -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; diff --git a/dbms/src/Common/ThreadPool.h b/dbms/src/Common/ThreadPool.h index 3a5e4b9a81e..9d5582db50c 100644 --- a/dbms/src/Common/ThreadPool.h +++ b/dbms/src/Common/ThreadPool.h @@ -216,18 +216,3 @@ private: /// Recommended thread pool for the case when multiple thread pools are created and destroyed. using ThreadPool = ThreadPoolImpl; - - -/// 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);