Loading...
Searching...
No Matches
L4Re::Util::Ref_del_cap< T > Struct Template Reference
L4Re C++ Interface » L4Re Util C++ Interface » L4Re Capability API

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

`#include <cap_alloc>`

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

  T | Type 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).
L4_INVALID_CAP
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:153
L4Re::Util::cap_alloc
_Cap_alloc & cap_alloc
Capability allocator.
L4Re::chksys
long chksys(long err, char const *extra="", long ret=0)
Generate C++ exception on error.
Definition error_helper:72

Definition at line 183 of file cap_alloc.

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

- l4/re/util/cap_alloc