mirror of https://github.com/oxen-io/oxen-core.git
Replace a few boost::bind's with lambda
This commit is contained in:
parent
ae344c2534
commit
19ca0e21ee
|
@ -256,20 +256,20 @@ namespace epee
|
|||
|
||||
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \
|
||||
if(!is_notify && command_id == command) \
|
||||
{handled=true;using namespace boost::placeholders;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in, typename_out>(this, command, in_buff, buff_out, boost::bind(func, this, _1, _2, _3, _4), context);}
|
||||
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in, typename_out>(this, command, in_buff, buff_out, [this](auto&&...v) { return func(std::forward<decltype(v)>(v)...); }, context);}
|
||||
|
||||
#define HANDLE_INVOKE_T2(COMMAND, func) \
|
||||
if(!is_notify && COMMAND::ID == command) \
|
||||
{handled=true;using namespace boost::placeholders;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename COMMAND::request, typename COMMAND::response>(command, in_buff, buff_out, boost::bind(func, this, _1, _2, _3, _4), context);}
|
||||
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename COMMAND::request, typename COMMAND::response>(command, in_buff, buff_out, [this](auto&&...v) { return func(std::forward<decltype(v)>(v)...); }, context);}
|
||||
|
||||
|
||||
#define HANDLE_NOTIFY2(command_id, func, type_name_in) \
|
||||
if(is_notify && command_id == command) \
|
||||
{handled=true;using namespace boost::placeholders;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in>(this, command, in_buff, boost::bind(func, this, _1, _2, _3), context);}
|
||||
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, type_name_in>(this, command, in_buff, [this](auto&&...v) { return func(std::forward<decltype(v)>(v)...); }, context);}
|
||||
|
||||
#define HANDLE_NOTIFY_T2(NOTIFY, func) \
|
||||
if(is_notify && NOTIFY::ID == command) \
|
||||
{handled=true;using namespace boost::placeholders;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename NOTIFY::request>(this, command, in_buff, boost::bind(func, this, _1, _2, _3), context);}
|
||||
{handled=true;return epee::net_utils::buff_to_t_adapter<internal_owner_type_name, typename NOTIFY::request>(this, command, in_buff, [this](auto&&...v) { return func(std::forward<decltype(v)>(v)...); }, context);}
|
||||
|
||||
|
||||
#define CHAIN_INVOKE_MAP2(func) \
|
||||
|
|
|
@ -236,7 +236,7 @@ namespace cryptonote
|
|||
m_stop = false;
|
||||
m_thread_index = 0;
|
||||
for(size_t i = 0; i != m_threads_total; i++)
|
||||
m_threads.push_back(boost::thread(m_attrs, boost::bind(&miner::worker_thread, this, false)));
|
||||
m_threads.emplace_back(m_attrs, [this] { return worker_thread(false); });
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
void miner::init_options(boost::program_options::options_description& desc)
|
||||
|
@ -340,7 +340,7 @@ namespace cryptonote
|
|||
|
||||
for(size_t i = 0; i != m_threads_total; i++)
|
||||
{
|
||||
m_threads.push_back(boost::thread(m_attrs, boost::bind(&miner::worker_thread, this, slow_mining)));
|
||||
m_threads.emplace_back(m_attrs, [=] { return worker_thread(slow_mining); });
|
||||
}
|
||||
|
||||
if (threads_count == 0)
|
||||
|
|
|
@ -4640,7 +4640,7 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync)
|
|||
{
|
||||
m_sync_counter = 0;
|
||||
m_bytes_to_sync = 0;
|
||||
m_async_service.dispatch(boost::bind(&Blockchain::store_blockchain, this));
|
||||
m_async_service.dispatch([this] { return store_blockchain(); });
|
||||
}
|
||||
else if(m_db_sync_mode == db_sync)
|
||||
{
|
||||
|
@ -4971,7 +4971,8 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
|
|||
unsigned nblocks = batches;
|
||||
if (i < extra)
|
||||
++nblocks;
|
||||
tpool.submit(&waiter, boost::bind(&Blockchain::block_longhash_worker, this, thread_height, epee::span<const block>(&blocks[thread_height - height], nblocks), std::ref(maps[i])), true);
|
||||
tpool.submit(&waiter, [this, thread_height, blocks=epee::span<const block>(&blocks[thread_height - height], nblocks), &map=maps[i]]
|
||||
{ block_longhash_worker(thread_height, blocks, map); }, true);
|
||||
thread_height += nblocks;
|
||||
}
|
||||
|
||||
|
@ -5114,7 +5115,8 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
|
|||
for (size_t i = 0; i < amounts.size(); i++)
|
||||
{
|
||||
uint64_t amount = amounts[i];
|
||||
tpool.submit(&waiter, boost::bind(&Blockchain::output_scan_worker, this, amount, std::cref(offset_map[amount]), std::ref(tx_map[amount])), true);
|
||||
tpool.submit(&waiter, [this, amount, &offsets=offset_map[amount], &outputs=tx_map[amount]]
|
||||
{ output_scan_worker(amount, offsets, outputs); }, true);
|
||||
}
|
||||
waiter.wait(&tpool);
|
||||
}
|
||||
|
|
|
@ -69,18 +69,18 @@ namespace cryptonote
|
|||
t_cryptonote_protocol_handler(t_core& rcore, bool offline = false);
|
||||
|
||||
BEGIN_INVOKE_MAP2(cryptonote_protocol_handler)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_TRANSACTIONS, &cryptonote_protocol_handler::handle_notify_new_transactions)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_GET_BLOCKS, &cryptonote_protocol_handler::handle_request_get_blocks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_GET_BLOCKS, &cryptonote_protocol_handler::handle_response_get_blocks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_GET_TXS, &cryptonote_protocol_handler::handle_request_get_txs)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_CHAIN, &cryptonote_protocol_handler::handle_request_chain)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_CHAIN_ENTRY, &cryptonote_protocol_handler::handle_response_chain_entry)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_FLUFFY_BLOCK, &cryptonote_protocol_handler::handle_notify_new_fluffy_block)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_FLUFFY_MISSING_TX, &cryptonote_protocol_handler::handle_request_fluffy_missing_tx)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_UPTIME_PROOF, &cryptonote_protocol_handler::handle_uptime_proof)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_SERVICE_NODE_VOTE, &cryptonote_protocol_handler::handle_notify_new_service_node_vote)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_BLOCK_BLINKS, &cryptonote_protocol_handler::handle_request_block_blinks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_BLOCK_BLINKS, &cryptonote_protocol_handler::handle_response_block_blinks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_TRANSACTIONS, handle_notify_new_transactions)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_GET_BLOCKS, handle_request_get_blocks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_GET_BLOCKS, handle_response_get_blocks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_GET_TXS, handle_request_get_txs)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_CHAIN, handle_request_chain)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_CHAIN_ENTRY, handle_response_chain_entry)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_FLUFFY_BLOCK, handle_notify_new_fluffy_block)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_FLUFFY_MISSING_TX, handle_request_fluffy_missing_tx)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_UPTIME_PROOF, handle_uptime_proof)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_NEW_SERVICE_NODE_VOTE, handle_notify_new_service_node_vote)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_BLOCK_BLINKS, handle_request_block_blinks)
|
||||
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_BLOCK_BLINKS, handle_response_block_blinks)
|
||||
END_INVOKE_MAP2()
|
||||
|
||||
bool on_idle();
|
||||
|
|
|
@ -287,10 +287,10 @@ namespace nodetool
|
|||
if (is_filtered_command(context.m_remote_address, command))
|
||||
return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED;
|
||||
|
||||
HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, &node_server::handle_handshake)
|
||||
HANDLE_INVOKE_T2(COMMAND_TIMED_SYNC, &node_server::handle_timed_sync)
|
||||
HANDLE_INVOKE_T2(COMMAND_PING, &node_server::handle_ping)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_SUPPORT_FLAGS, &node_server::handle_get_support_flags)
|
||||
HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, handle_handshake)
|
||||
HANDLE_INVOKE_T2(COMMAND_TIMED_SYNC, handle_timed_sync)
|
||||
HANDLE_INVOKE_T2(COMMAND_PING, handle_ping)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_SUPPORT_FLAGS, handle_get_support_flags)
|
||||
CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(m_payload_handler, typename t_payload_net_handler::connection_context&)
|
||||
END_INVOKE_MAP2()
|
||||
|
||||
|
|
|
@ -83,12 +83,12 @@ namespace
|
|||
CHAIN_LEVIN_NOTIFY_MAP2(test_connection_context);
|
||||
|
||||
BEGIN_INVOKE_MAP2(srv_levin_commands_handler)
|
||||
HANDLE_NOTIFY_T2(CMD_CLOSE_ALL_CONNECTIONS, &srv_levin_commands_handler::handle_close_all_connections)
|
||||
HANDLE_NOTIFY_T2(CMD_SHUTDOWN, &srv_levin_commands_handler::handle_shutdown)
|
||||
HANDLE_NOTIFY_T2(CMD_SEND_DATA_REQUESTS, &srv_levin_commands_handler::handle_send_data_requests)
|
||||
HANDLE_INVOKE_T2(CMD_GET_STATISTICS, &srv_levin_commands_handler::handle_get_statistics)
|
||||
HANDLE_INVOKE_T2(CMD_RESET_STATISTICS, &srv_levin_commands_handler::handle_reset_statistics)
|
||||
HANDLE_INVOKE_T2(CMD_START_OPEN_CLOSE_TEST, &srv_levin_commands_handler::handle_start_open_close_test)
|
||||
HANDLE_NOTIFY_T2(CMD_CLOSE_ALL_CONNECTIONS, handle_close_all_connections)
|
||||
HANDLE_NOTIFY_T2(CMD_SHUTDOWN, handle_shutdown)
|
||||
HANDLE_NOTIFY_T2(CMD_SEND_DATA_REQUESTS, handle_send_data_requests)
|
||||
HANDLE_INVOKE_T2(CMD_GET_STATISTICS, handle_get_statistics)
|
||||
HANDLE_INVOKE_T2(CMD_RESET_STATISTICS, handle_reset_statistics)
|
||||
HANDLE_INVOKE_T2(CMD_START_OPEN_CLOSE_TEST, handle_start_open_close_test)
|
||||
END_INVOKE_MAP2()
|
||||
|
||||
int handle_close_all_connections(int command, const CMD_CLOSE_ALL_CONNECTIONS::request& req, test_connection_context& context)
|
||||
|
|
Loading…
Reference in New Issue