Allow the use of a comparator that has a value, and for that
comparator to be adjusted at runtime for the purposes for get_next
sort order. Since get_next uses the weak_refs map, that is the
only map that needs to be rebuilt.
We assume, for simplicity, that the comparator can be constructed
with no arguments with some default... otherwise this is messier.
Signed-off-by: Sage Weil <sage@redhat.com>
}
}
+ /// adjust container comparator (for purposes of get_next sort order)
+ void reset_comparator(C comp) {
+ // get_next uses weak_refs; that's the only container we need to
+ // reorder.
+ map<K, pair<WeakVPtr, V*>, C> temp;
+
+ Mutex::Locker l(lock);
+ temp.swap(weak_refs);
+
+ // reconstruct with new comparator
+ weak_refs = map<K, pair<WeakVPtr, V*>, C>(comp);
+ weak_refs.insert(temp.begin(), temp.end());
+ }
+
+ C get_comparator() {
+ return weak_refs.key_comp();
+ }
+
void set_cct(CephContext *c) {
cct = c;
}