Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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.
251task = std::move(m_work_queue.front());252m_work_queue.pop();253}254task();255return true;256}258/**259* @brief Stop accepting new tasks and begin asynchronous shutdown.260*261* Wakes all worker threads so they can drain the queue and exit.262* Unlike Stop(), this function does not wait for threads to finish.263*264* Note: The next step in the pool lifecycle is calling Stop(), which265* releases any dangling resources and resets the pool state266* for shutdown or restart.267*/268void Interrupt() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)269{270WITH_LOCK(m_mutex, m_interrupt = true);271m_cv.notify_all();272}274size_t WorkQueueSize() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)275{276return WITH_LOCK(m_mutex, return m_work_queue.size());277}279size_t WorkersCount() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)280{281return WITH_LOCK(m_mutex, return m_workers.size());282}283};285constexpr std::string_view SubmitErrorString(const ThreadPool::SubmitError err) noexcept {286switch (err) {287case ThreadPool::SubmitError::Inactive:288return "No active workers";289case ThreadPool::SubmitError::Interrupted:290return "Interrupted";291}292Assume(false); // Unreachable293return "Unknown error";294}296#endif // BITCOIN_UTIL_THREADPOOL_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.