Storage: Add more Dispatcher accessors.

This commit is contained in:
Peter Johnson
2015-07-29 20:33:13 -07:00
parent 9a621e9272
commit f6576b18f7
2 changed files with 21 additions and 6 deletions

View File

@@ -23,9 +23,8 @@ Storage::Storage() {
Storage::~Storage() {}
std::shared_ptr<StorageEntry> Storage::CreateEntry(StringRef name,
std::shared_ptr<Value> value,
unsigned int flags) {
std::shared_ptr<StorageEntry> Storage::DispatchCreateEntry(
StringRef name, std::shared_ptr<Value> value, unsigned int flags) {
std::lock_guard<std::mutex> lock(m_mutex);
auto& entry = m_entries[name];
if (!entry) entry = std::make_shared<StorageEntry>(name);
@@ -34,6 +33,20 @@ std::shared_ptr<StorageEntry> Storage::CreateEntry(StringRef name,
return entry;
}
void Storage::DispatchDeleteEntry(StringRef name) {
std::lock_guard<std::mutex> lock(m_mutex);
auto i = m_entries.find(name);
if (i == m_entries.end()) return;
auto entry = i->getValue();
m_entries.erase(i); // erase from map
}
void Storage::DispatchDeleteAllEntries() {
std::lock_guard<std::mutex> lock(m_mutex);
if (m_entries.empty()) return;
m_entries.clear();
}
void Storage::GetUpdates(UpdateMap* updates, bool* delete_all) {
std::lock_guard<std::mutex> lock(m_mutex);
m_updates.swap(*updates);