L4Re - L4 Runtime Environment
L4Re::Util::Ref_del_cap< T > Struct Template Reference

Automatic capability that implements automatic free and unmap+delete of the capability selector. More...

+ Collaboration diagram for L4Re::Util::Ref_del_cap< T >:

Detailed Description

template<typename T>
struct L4Re::Util::Ref_del_cap< T >

Automatic capability that implements automatic free and unmap+delete of the capability selector.

Template Parameters
TType of the object that is referred by the capability.

This kind of automatic capability implements a counted reference to a capability selector. The capability shall be unmapped and freed when the reference count in the allocator goes to zero. The main difference to Ref_cap is that the unmap is done with the deletion flag enabled and this leads to the deletion of the object if the current task holds appropriate deletion rights.

Usage:

L4Re::Util::Ref_del_cap<L4Re::Dataspace>::Cap global_ds_cap;
{
L4Re::Util::Ref_del_cap<L4Re::Dataspace>::Cap
ds_cap(L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>());
// reference count for the allocated cap selector is now 1
// use the dataspace cap
L4Re::chksys(mem_alloc->alloc(4096, ds_cap.get()));
global_ds_cap = ds_cap;
// reference count is now 2
...
}
// reference count dropped to 1 (ds_cap is no longer existing).
...
global_ds_cap = L4_INVALID_CAP;
// reference count dropped to 0 (data space shall be deleted).

Definition at line 272 of file cap_alloc.


The documentation for this struct was generated from the following file: