Allocator_avl: apply_any method

Provide an `apply_any` method for accessing any member of the allocator,
this is provided for destructing members of the allocator.

Ref #2996
This commit is contained in:
Ehmry - 2018-10-04 16:39:57 +02:00 committed by Christian Helmuth
parent 9ca214eee8
commit 3958ea50a0
1 changed files with 20 additions and 0 deletions

View File

@ -381,6 +381,26 @@ class Genode::Allocator_avl_tpl : public Allocator_avl_base
_metadata.backing_store(md_bs);
return ret;
}
/**
* Apply functor 'fn' to the metadata of an arbitrary
* member of the allocator. This method is provided for
* destructing each member of the allocator. Calling
* the method repeatedly without removing or inserting
* members will produce the same member.
*/
template <typename FUNC>
bool apply_any(FUNC const &fn)
{
addr_t addr = 0;
if (any_block_addr(&addr)) {
if (BMDT *b = metadata((void*)addr)) {
fn((BMDT&)*b);
return true;
}
}
return false;
}
};
#endif /* _INCLUDE__BASE__ALLOCATOR_AVL_H_ */