mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
std::atomic_flag has no copy/move constructor, can't have a vector
This commit is contained in:
parent
df53c0a595
commit
1b462261b8
1 changed files with 7 additions and 9 deletions
|
@ -257,15 +257,13 @@ namespace nodetool
|
||||||
// for some time yet.
|
// for some time yet.
|
||||||
|
|
||||||
std::vector<std::vector<std::string>> dns_results;
|
std::vector<std::vector<std::string>> dns_results;
|
||||||
|
|
||||||
std::vector<std::atomic_flag> dns_finished;
|
|
||||||
|
|
||||||
dns_results.resize(m_seed_nodes_list.size());
|
dns_results.resize(m_seed_nodes_list.size());
|
||||||
dns_finished.resize(m_seed_nodes_list.size());
|
|
||||||
|
std::unique_ptr<std::atomic_flag[]> dns_finished(new std::atomic_flag[m_seed_nodes_list.size()]);
|
||||||
|
|
||||||
// set each flag, thread will release when finished
|
// set each flag, thread will release when finished
|
||||||
for (auto& u : dns_finished)
|
for (uint64_t i = 0; i < m_seed_nodes_list.size(); ++i)
|
||||||
u.test_and_set();
|
dns_finished[i].test_and_set();
|
||||||
|
|
||||||
uint64_t result_index = 0;
|
uint64_t result_index = 0;
|
||||||
for (const std::string& addr_str : m_seed_nodes_list)
|
for (const std::string& addr_str : m_seed_nodes_list)
|
||||||
|
@ -290,12 +288,12 @@ namespace nodetool
|
||||||
{
|
{
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(sleep_interval_ms));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(sleep_interval_ms));
|
||||||
bool all_done = false;
|
bool all_done = false;
|
||||||
for (auto& done : dns_finished)
|
for (uint64_t i = 0; i < m_seed_nodes_list.size(); ++i)
|
||||||
{
|
{
|
||||||
if (done.test_and_set())
|
if (dns_finished[i].test_and_set())
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
done.clear();
|
dns_finished[i].clear();
|
||||||
all_done = true;
|
all_done = true;
|
||||||
}
|
}
|
||||||
if (all_done)
|
if (all_done)
|
||||||
|
|
Loading…
Reference in a new issue