2022-03-16 18:41:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/ThreadPool.h>
|
2022-09-07 15:44:29 +00:00
|
|
|
#include <future>
|
2022-03-16 18:41:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-09-07 15:44:29 +00:00
|
|
|
/// High-order function to run callbacks (functions with 'void()' signature) somewhere asynchronously.
|
|
|
|
template <typename Result>
|
|
|
|
using ThreadPoolCallbackRunner = std::function<std::future<Result>(std::function<Result()> &&, size_t priority)>;
|
2022-03-16 18:41:41 +00:00
|
|
|
|
2022-09-07 15:44:29 +00:00
|
|
|
/// Creates CallbackRunner that runs every callback with 'pool->scheduleOrThrow()'.
|
|
|
|
template <typename Result>
|
|
|
|
ThreadPoolCallbackRunner<Result> threadPoolCallbackRunner(ThreadPool & pool, const std::string & thread_name);
|
2022-03-16 18:41:41 +00:00
|
|
|
|
|
|
|
}
|