Skip to content

Commit

Permalink
Using remove_if.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Jan 27, 2017
1 parent e88fed4 commit d4a4623
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions rai/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,20 @@ void rai::work_pool::loop (uint64_t thread)
void rai::work_pool::cancel (rai::uint256_union const & root_a)
{
std::lock_guard <std::mutex> lock (mutex);
for (auto i (pending.begin ()), n (pending.end ()); i != n; ++i)
pending.remove_if ([&root_a] (decltype (pending)::value_type const & item_a)
{
if (i->first == root_a)
bool result;
if (item_a.first == root_a)
{
i->second->set_value (boost::none);
pending.erase (i);
item_a.second->set_value (boost::none);
result = true;
}
};
else
{
result = false;
}
return result;
});
}

bool rai::work_pool::work_validate (rai::block_hash const & root_a, uint64_t work_a)
Expand Down

0 comments on commit d4a4623

Please sign in to comment.