The SharedPtrRegistry::get_next() method with a value of type VPtr
instead of V is added because it is sometime more convenient to not
copy the value when walking the registry. The
SharedPtrRegistry::empty() predicate method is added.
Signed-off-by: Loic Dachary <loic@dachary.org>
lock("SharedPtrRegistry::lock")
{}
+ bool empty() {
+ Mutex::Locker l(lock);
+ return contents.empty();
+ }
+
+ bool get_next(const K &key, pair<K, VPtr> *next) {
+ VPtr next_val;
+ Mutex::Locker l(lock);
+ typename map<K, WeakVPtr>::iterator i = contents.upper_bound(key);
+ while (i != contents.end() &&
+ !(next_val = i->second.lock()))
+ ++i;
+ if (i == contents.end())
+ return false;
+ if (next)
+ *next = make_pair(i->first, next_val);
+ return true;
+ }
+
+
bool get_next(const K &key, pair<K, V> *next) {
VPtr next_val;
Mutex::Locker l(lock);