}
}
+ /*
+ * Clears unreferenced elements from the lru set [from, to]
+ */
+ void clear_range(
+ const K& from,
+ const K& to) {
+ auto from_iter = lru_set.lower_bound(from);
+ auto to_iter = lru_set.upper_bound(to);
+ for (auto i = from_iter; i != to_iter; ) {
+ if (!(*i).lru) {
+ unreferenced_list.erase(lru_list_t::s_iterator_to(*i));
+ i = lru_set.erase_and_dispose(i, [](auto *p)
+ { delete p; } );
+ } else {
+ i++;
+ }
+ }
+ }
+
+ template <class F>
+ void for_each(F&& f) {
+ for (auto& v : lru_set) {
+ access(v);
+ f(TRef{static_cast<T*>(&v)});
+ }
+ }
+
/**
* Returns the TRef corresponding to k if it exists or
* nullptr otherwise.
evict();
}
+ ~intrusive_lru() {
+ set_target_size(0);
+ }
+
friend void intrusive_ptr_add_ref<>(intrusive_lru_base<Config> *);
friend void intrusive_ptr_release<>(intrusive_lru_base<Config> *);
};