mirror of https://github.com/bitcoin/bitcoin.git
kernel: Add chainstate manager option for setting worker threads
Re-use the same pattern used for the context options. This allows users to set the number of threads used in the validation thread pool.
This commit is contained in:
parent
dee984def6
commit
783db175aa
|
@ -685,6 +685,12 @@ btck_ChainstateManagerOptions* btck_chainstate_manager_options_create(const btck
|
|||
}
|
||||
}
|
||||
|
||||
void btck_chainstate_manager_options_set_worker_threads_num(btck_ChainstateManagerOptions* opts, int worker_threads)
|
||||
{
|
||||
LOCK(btck_ChainstateManagerOptions::get(opts).m_mutex);
|
||||
btck_ChainstateManagerOptions::get(opts).m_chainman_options.worker_threads_num = worker_threads;
|
||||
}
|
||||
|
||||
void btck_chainstate_manager_options_destroy(btck_ChainstateManagerOptions* options)
|
||||
{
|
||||
delete options;
|
||||
|
|
|
@ -714,6 +714,18 @@ BITCOINKERNEL_API btck_ChainstateManagerOptions* BITCOINKERNEL_WARN_UNUSED_RESUL
|
|||
const char* blocks_directory,
|
||||
size_t blocks_directory_len) BITCOINKERNEL_ARG_NONNULL(1, 2);
|
||||
|
||||
/**
|
||||
* @brief Set the number of available worker threads used during validation.
|
||||
*
|
||||
* @param[in] chainstate_manager_options Non-null, options to be set.
|
||||
* @param[in] worker_threads The number of worker threads that should be spawned in the thread pool
|
||||
* used for validation. When set to 0 no parallel verification is done.
|
||||
* The value range is clamped internally between 0 and 15.
|
||||
*/
|
||||
BITCOINKERNEL_API void btck_chainstate_manager_options_set_worker_threads_num(
|
||||
btck_ChainstateManagerOptions* chainstate_manager_options,
|
||||
int worker_threads) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* Destroy the chainstate manager options.
|
||||
*/
|
||||
|
|
|
@ -631,6 +631,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void SetWorkerThreads(int worker_threads)
|
||||
{
|
||||
btck_chainstate_manager_options_set_worker_threads_num(get(), worker_threads);
|
||||
}
|
||||
|
||||
friend class ChainMan;
|
||||
};
|
||||
|
||||
|
|
|
@ -512,5 +512,6 @@ BOOST_AUTO_TEST_CASE(btck_chainman_tests)
|
|||
auto context{create_context(notifications, ChainType::MAINNET)};
|
||||
|
||||
ChainstateManagerOptions chainman_opts{context, test_directory.m_directory.string(), (test_directory.m_directory / "blocks").string()};
|
||||
chainman_opts.SetWorkerThreads(4);
|
||||
ChainMan chainman{context, chainman_opts};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue