diff options
author | Thomas Winget <tewinget@gmail.com> | 2014-12-15 17:43:12 -0500 |
---|---|---|
committer | Thomas Winget <tewinget@gmail.com> | 2014-12-15 17:43:12 -0500 |
commit | 1b462261b88da00f20c743b8638969b8f1ff2a19 (patch) | |
tree | 0f01e2e9db5bb74a8046e6dbd3e1acd5cca71df6 /src/p2p | |
parent | small typo in previous commit (diff) | |
download | monero-1b462261b88da00f20c743b8638969b8f1ff2a19.tar.xz |
std::atomic_flag has no copy/move constructor, can't have a vector
Diffstat (limited to 'src/p2p')
-rw-r--r-- | src/p2p/net_node.inl | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index ee2d3974f..17a81db79 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -257,15 +257,13 @@ namespace nodetool // for some time yet. std::vector<std::vector<std::string>> dns_results; - - std::vector<std::atomic_flag> dns_finished; - 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 - for (auto& u : dns_finished) - u.test_and_set(); + for (uint64_t i = 0; i < m_seed_nodes_list.size(); ++i) + dns_finished[i].test_and_set(); uint64_t result_index = 0; 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)); 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; else - done.clear(); + dns_finished[i].clear(); all_done = true; } if (all_done) |