Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2024-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_UTIL_TASK_RUNNER_H6#define BITCOIN_UTIL_TASK_RUNNER_H8#include <cstddef>9#include <functional>11namespace util {13/** @file14* This header provides an interface and simple implementation for a task15* runner. Another threaded, serial implementation using a queue is available in16* the scheduler module's SerialTaskRunner.17*/19class TaskRunnerInterface20{21public:22virtual ~TaskRunnerInterface() = default;24/**25* The callback can either be queued for later/asynchronous/threaded26* processing, or be executed immediately for synchronous processing.27*/29virtual void insert(std::function<void()> func) = 0;31/**32* Forces the processing of all pending events.33*/34virtual void flush() = 0;36/**37* Returns the number of currently pending events.38*/39virtual size_t size() = 0;40};42class ImmediateTaskRunner : public TaskRunnerInterface43{44public:45void insert(std::function<void()> func) override { func(); }46void flush() override {}47size_t size() override { return 0; }48};50} // namespace util52#endif // BITCOIN_UTIL_TASK_RUNNER_H