Struct MemoryOwner<T>
Represents unified representation of the memory rented using various types of memory pools.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public struct MemoryOwner<T> : IMemoryOwner<T>, IDisposable, IConvertible<Memory<T>>
Type Parameters
Name | Description |
---|---|
T | The type of the items in the memory pool. |
Constructors
| Improve this Doc View SourceMemoryOwner(T[])
Wraps the array as if it was rented.
Declaration
public MemoryOwner(T[] array)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to wrap. |
MemoryOwner(T[], Int32)
Wraps the array as if it was rented.
Declaration
public MemoryOwner(T[] array, int length)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to wrap. |
Int32 | length | The length of the array. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
MemoryOwner(ArrayPool<T>, Int32)
Rents the array from the pool.
Declaration
public MemoryOwner(ArrayPool<T> pool, int length)
Parameters
Type | Name | Description |
---|---|---|
ArrayPool<T> | pool | The array pool. |
Int32 | length | The length of the array. |
MemoryOwner(MemoryPool<T>, Int32)
Rents the memory from the pool.
Declaration
public MemoryOwner(MemoryPool<T> pool, int length = -1)
Parameters
Type | Name | Description |
---|---|---|
MemoryPool<T> | pool | The memory pool. |
Int32 | length | The number of elements to rent; or |
MemoryOwner(Func<IMemoryOwner<T>>)
Rents the memory.
Declaration
public MemoryOwner(Func<IMemoryOwner<T>> provider)
Parameters
Type | Name | Description |
---|---|---|
Func<IMemoryOwner<T>> | provider | The memory provider. |
MemoryOwner(Func<Int32, IMemoryOwner<T>>, Int32)
Retns the memory.
Declaration
public MemoryOwner(Func<int, IMemoryOwner<T>> provider, int length)
Parameters
Type | Name | Description |
---|---|---|
Func<Int32, IMemoryOwner<T>> | provider | The memory provider. |
Int32 | length | The number of elements to rent. |
Properties
| Improve this Doc View SourceIsEmpty
Determines whether this memory is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets managed pointer to the item in the rented memory.
Declaration
public T this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the element in memory. |
Property Value
Type | Description |
---|---|
T | The managed pointer to the item. |
Length
Gets length of the rented memory, in bytes.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Memory
Gets the memory belonging to this owner.
Declaration
public Memory<T> Memory { get; }
Property Value
Type | Description |
---|---|
Memory<T> | The memory belonging to this owner. |
Methods
| Improve this Doc View SourceDispose()
Releases rented memory.
Declaration
public void Dispose()
Explicit Interface Implementations
| Improve this Doc View SourceIConvertible<Memory<T>>.Convert()
Declaration
Memory<T> IConvertible<Memory<T>>.Convert()
Returns
Type | Description |
---|---|
Memory<T> |