ClickHouse/src/IO/IOThreadPool.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
718 B
C++
Raw Normal View History

2022-03-09 13:57:33 +00:00
#include <IO/IOThreadPool.h>
#include "Core/Field.h"
namespace DB
{
2022-03-11 13:38:19 +00:00
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
2022-03-09 13:57:33 +00:00
std::unique_ptr<ThreadPool> IOThreadPool::instance;
void IOThreadPool::initialize(size_t max_threads, size_t max_free_threads, size_t queue_size)
{
if (instance)
{
2022-03-16 14:59:06 +00:00
throw Exception(ErrorCodes::LOGICAL_ERROR, "The IO thread pool is initialized twice");
2022-03-09 13:57:33 +00:00
}
instance = std::make_unique<ThreadPool>(max_threads, max_free_threads, queue_size, false /*shutdown_on_exception*/);
}
ThreadPool & IOThreadPool::get()
{
if (!instance)
{
2022-03-16 14:59:06 +00:00
throw Exception(ErrorCodes::LOGICAL_ERROR, "The IO thread pool is not initialized");
2022-03-09 13:57:33 +00:00
}
return *instance;
}
}