mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Storage: Delete functions now delete from map.
This is ok due to the map storing shared_ptr.
This commit is contained in:
@@ -88,17 +88,19 @@ unsigned int Storage::GetEntryFlags(StringRef name) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Storage::DeleteEntry(StringRef name) {
|
void Storage::DeleteEntry(StringRef name) {
|
||||||
auto entry = FindEntry(name);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (!entry) return;
|
auto i = m_entries.find(name);
|
||||||
if (entry->value()) {
|
if (i == m_entries.end()) return;
|
||||||
entry->set_value(nullptr);
|
auto entry = i->getValue();
|
||||||
m_updates.push(Update{entry, Update::kDelete}); // put on update queue
|
m_entries.erase(i); // erase from map
|
||||||
}
|
// if it had a value, put on update queue
|
||||||
|
if (entry->value()) m_updates.push(Update{entry, Update::kDelete});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Storage::DeleteAllEntries() {
|
void Storage::DeleteAllEntries() {
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
for (auto& i : m_entries) i.getValue()->set_value(nullptr);
|
if (m_entries.empty()) return;
|
||||||
|
m_entries.clear();
|
||||||
m_updates.push(Update{nullptr, Update::kDeleteAll}); // put on update queue
|
m_updates.push(Update{nullptr, Update::kDeleteAll}); // put on update queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user