mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
Replace thread "pool" with a single thread
When you have a comment just before your thread pool initialization that reads: // we only need 1 that is a pretty good indicator that you don't need a thread *pool* for the thing you are doing. Replace it with a single std::thread.
This commit is contained in:
parent
29b18f6cc3
commit
5a27030ff8
|
@ -508,8 +508,7 @@ bool Blockchain::init(BlockchainDB* db, sqlite3 *lns_db, const network_type nett
|
|||
// create general purpose async service queue
|
||||
|
||||
m_async_work_idle = std::unique_ptr < boost::asio::io_service::work > (new boost::asio::io_service::work(m_async_service));
|
||||
// we only need 1
|
||||
m_async_pool.create_thread([this] { m_async_service.run(); });
|
||||
m_async_thread = std::thread{[this] { m_async_service.run(); }};
|
||||
|
||||
#if defined(PER_BLOCK_CHECKPOINT)
|
||||
if (m_nettype != FAKECHAIN)
|
||||
|
@ -647,7 +646,7 @@ bool Blockchain::deinit()
|
|||
|
||||
// stop async service
|
||||
m_async_work_idle.reset();
|
||||
m_async_pool.join_all();
|
||||
m_async_thread.join();
|
||||
m_async_service.stop();
|
||||
|
||||
// as this should be called if handling a SIGSEGV, need to check
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <boost/multi_index/global_fun.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
@ -1118,7 +1117,7 @@ namespace cryptonote
|
|||
difficulty_type m_difficulty_for_next_block;
|
||||
|
||||
boost::asio::io_service m_async_service;
|
||||
boost::thread_group m_async_pool;
|
||||
std::thread m_async_thread;
|
||||
std::unique_ptr<boost::asio::io_service::work> m_async_work_idle;
|
||||
|
||||
// some invalid blocks
|
||||
|
|
Loading…
Reference in a new issue