Struct MemoryRental<T>
Represents the memory obtained from the pool or allocated on the stack or heap.
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public struct MemoryRental<T>
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the rented memory. |
Constructors
| Improve this Doc View SourceMemoryRental(Span<T>)
Rents the memory referenced by the span.
Declaration
public MemoryRental(Span<T> span)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Span<T> | span | The span that references the memory to rent. |
MemoryRental(MemoryPool<T>, Int32)
Rents the memory from the pool.
Declaration
public MemoryRental(MemoryPool<T> pool, int minBufferSize)
Parameters
Type | Name | Description |
---|---|---|
MemoryPool<T> | pool | The memory pool. |
Int32 | minBufferSize | The minimum size of the memory to rent. |
MemoryRental(Int32)
Rents the memory from
Declaration
public MemoryRental(int minBufferSize)
Parameters
Type | Name | Description |
---|---|---|
Int32 | minBufferSize | The minimum size of the memory to rent. |
Properties
| Improve this Doc View SourceIsEmpty
Gets a value indicating that this object doesn't reference rented memory.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets the memory element by its index.
Declaration
public T this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the memory element. |
Property Value
Type | Description |
---|---|
T | The managed pointer to the memory element. |
Length
Gets length of the rented memory.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Span
Gets the rented memory.
Declaration
public Span<T> Span { get; }
Property Value
Type | Description |
---|---|
DotNext.Span<T> |
Methods
| Improve this Doc View SourceDispose()
Returns the memory back to the pool.
Declaration
public void Dispose()
GetPinnableReference()
Obtains managed pointer to the first element of the rented array.
Declaration
public T GetPinnableReference()
Returns
Type | Description |
---|---|
T | The managed pointer to the first element of the rented array. |
ToString()
Gets textual representation of the rented memory.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of the rented memory. |
Operators
| Improve this Doc View SourceImplicit(Span<T> to MemoryRental<T>)
Converts the reference to the already allocated memory into the rental object.
Declaration
public static implicit operator MemoryRental<T>(Span<T> span)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Span<T> | span | The allocated memory to convert. |
Returns
Type | Description |
---|---|
MemoryRental<T> |