* Provides a registry of shared_ptr<V> indexed by K while
* the references are alive.
*/
-template <class K, class V>
+template <class K, class V, class C = std::less<K> >
class SharedPtrRegistry {
public:
typedef ceph::shared_ptr<V> VPtr;
private:
Mutex lock;
Cond cond;
- map<K, pair<WeakVPtr, V*> > contents;
+ map<K, pair<WeakVPtr, V*>, C> contents;
class OnRemoval {
- SharedPtrRegistry<K,V> *parent;
+ SharedPtrRegistry<K,V,C> *parent;
K key;
public:
- OnRemoval(SharedPtrRegistry<K,V> *parent, K key) :
+ OnRemoval(SharedPtrRegistry<K,V,C> *parent, K key) :
parent(parent), key(key) {}
void operator()(V *to_remove) {
{
Mutex::Locker l(parent->lock);
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
parent->contents.find(key);
if (i != parent->contents.end() &&
i->second.second == to_remove) {
{
Mutex::Locker l(lock);
VPtr next_val;
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
contents.upper_bound(key);
while (i != contents.end() &&
!(next_val = i->second.first.lock()))
bool get_next(const K &key, pair<K, V> *next) {
VPtr next_val;
Mutex::Locker l(lock);
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
contents.upper_bound(key);
while (i != contents.end() &&
!(next_val = i->second.first.lock()))
Mutex::Locker l(lock);
waiting++;
while (1) {
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
contents.find(key);
if (i != contents.end()) {
VPtr retval = i->second.first.lock();
Mutex::Locker l(lock);
waiting++;
while (1) {
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
contents.find(key);
if (i != contents.end()) {
VPtr retval = i->second.first.lock();
Mutex::Locker l(lock);
waiting++;
while (1) {
- typename map<K, pair<WeakVPtr, V*> >::iterator i =
+ typename map<K, pair<WeakVPtr, V*>, C>::iterator i =
contents.find(key);
if (i != contents.end()) {
VPtr retval = i->second.first.lock();