#include <nda/mem/handle.hpp>
template<typename T,
AddressSpace AdrSp>
struct nda::mem::handle_shared< T, AdrSp >
A handle for a memory block on the heap with shared ownership.
- Template Parameters
-
Definition at line 754 of file handle.hpp.
|
using | value_type = T |
| Value type of the data.
|
|
|
| handle_shared ()=default |
| Default constructor leaves the handle in a null state (nullptr and size 0).
|
|
template<Allocator A>
requires (A::address_space == address_space) |
| handle_shared (handle_heap< T, A > const &h) noexcept |
| Construct a shared handle from an nda::mem::handle_heap.
|
|
| handle_shared (T *data, size_t size, void *foreign_handle, void(*foreign_decref)(void *)) noexcept |
| Construct a handle from a shared object from a foreign library.
|
|
T * | data () const noexcept |
| Get a pointer to the stored data.
|
|
bool | is_null () const noexcept |
| Check if the handle is in a null state.
|
|
T const & | operator[] (long i) const noexcept |
| Subscript operator to access the data.
|
|
T & | operator[] (long i) noexcept |
| Subscript operator to access the data.
|
|
long | refcount () const noexcept |
| Get the reference count of the shared object.
|
|
long | size () const noexcept |
| Get the size of the handle.
|
|
◆ handle_shared() [1/2]
nda::mem::handle_shared< T, AdrSp >::handle_shared |
( |
T * | data, |
|
|
size_t | size, |
|
|
void * | foreign_handle, |
|
|
void(* | foreign_decref )(void *) ) |
|
inlinenoexcept |
Construct a handle from a shared object from a foreign library.
- Parameters
-
data | Pointer to the start of the shared data. |
size | Size of the data (number of elements). |
foreign_handle | Pointer to the shared object. |
foreign_decref | Function to decrease the reference count of the shared object. |
Definition at line 788 of file handle.hpp.
◆ handle_shared() [2/2]
template<Allocator A>
requires (A::address_space ==
address_space)
◆ data()
Get a pointer to the stored data.
- Returns
- Pointer to the start of the handled memory.
Definition at line 842 of file handle.hpp.
◆ is_null()
Check if the handle is in a null state.
- Returns
- True if the data is a
nullptr
(and the size is 0).
Definition at line 824 of file handle.hpp.
◆ operator[]() [1/2]
Subscript operator to access the data.
- Parameters
-
i | Index of the element to access. |
- Returns
- Const reference to the element at the given index.
Definition at line 818 of file handle.hpp.
◆ operator[]() [2/2]
Subscript operator to access the data.
- Parameters
-
i | Index of the element to access. |
- Returns
- Reference to the element at the given index.
Definition at line 810 of file handle.hpp.
◆ refcount()
Get the reference count of the shared object.
- Returns
- Reference count of the shared pointer.
Definition at line 836 of file handle.hpp.
◆ size()
Get the size of the handle.
- Returns
- Number of elements of type
T
in the handled memory.
Definition at line 848 of file handle.hpp.
The documentation for this struct was generated from the following file: