diff options
author | Max Kellermann <max@duempel.org> | 2014-02-26 08:39:44 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-27 20:49:13 +0100 |
commit | e9a85aa4e4d0634548b5c97461beb27ae5559338 (patch) | |
tree | 7cdfdd0ae0d990a8adbecc34f32d073627483205 /src/db/update/Queue.cxx | |
parent | 2a16fc74fd354484a70efcc5b6dbfcdd73ee5f5a (diff) | |
download | mpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.tar.gz mpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.tar.xz mpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.zip |
db/simple: mount points
A SimpleDatabase instance can now "mount" other Database instances at
certain locations. This is used to use a new SimpleDatabase instance
for each storage mount (issued with the "mount" protocol command).
Each such instance has its own database file, stored in the directory
that is specified with the "cache_directory" option.
Diffstat (limited to '')
-rw-r--r-- | src/db/update/Queue.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/db/update/Queue.cxx b/src/db/update/Queue.cxx index 096a39a8c..6d6d80131 100644 --- a/src/db/update/Queue.cxx +++ b/src/db/update/Queue.cxx @@ -21,12 +21,13 @@ #include "Queue.hxx" bool -UpdateQueue::Push(const char *path, bool discard, unsigned id) +UpdateQueue::Push(SimpleDatabase &db, Storage &storage, + const char *path, bool discard, unsigned id) { if (update_queue.size() >= MAX_UPDATE_QUEUE_SIZE) return false; - update_queue.emplace_back(path, discard, id); + update_queue.emplace_back(db, storage, path, discard, id); return true; } @@ -40,3 +41,27 @@ UpdateQueue::Pop() update_queue.pop_front(); return i; } + +void +UpdateQueue::Erase(SimpleDatabase &db) +{ + for (auto i = update_queue.begin(), end = update_queue.end(); + i != end;) { + if (i->db == &db) + i = update_queue.erase(i); + else + ++i; + } +} + +void +UpdateQueue::Erase(Storage &storage) +{ + for (auto i = update_queue.begin(), end = update_queue.end(); + i != end;) { + if (i->storage == &storage) + i = update_queue.erase(i); + else + ++i; + } +} |