Changeset View
Changeset View
Standalone View
Standalone View
src/validationinterface.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
//! Clear unregisters every previously registered callback, erasing every | //! Clear unregisters every previously registered callback, erasing every | ||||
//! map entry. After this call, the list may still contain callbacks that | //! map entry. After this call, the list may still contain callbacks that | ||||
//! are currently executing, but it will be cleared when they are done | //! are currently executing, but it will be cleared when they are done | ||||
//! executing. | //! executing. | ||||
void Clear() { | void Clear() { | ||||
LOCK(m_mutex); | LOCK(m_mutex); | ||||
for (auto it = m_list.begin(); it != m_list.end();) { | for (const auto &entry : m_map) { | ||||
it = --it->count ? std::next(it) : m_list.erase(it); | if (!--entry.second->count) m_list.erase(entry.second); | ||||
} | } | ||||
m_map.clear(); | m_map.clear(); | ||||
} | } | ||||
template <typename F> void Iterate(F &&f) { | template <typename F> void Iterate(F &&f) { | ||||
WAIT_LOCK(m_mutex, lock); | WAIT_LOCK(m_mutex, lock); | ||||
for (auto it = m_list.begin(); it != m_list.end();) { | for (auto it = m_list.begin(); it != m_list.end();) { | ||||
++it->count; | ++it->count; | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |