Class MemoryAllocator
Represents interop layer between .NET memory pools and MemoryAllocator<T>.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public static class MemoryAllocator
Methods
| Improve this Doc View SourceCreateArrayAllocator<T>()
Returns array allocator.
Declaration
public static MemoryAllocator<T> CreateArrayAllocator<T>()
Returns
| Type | Description |
|---|---|
| MemoryAllocator<T> | The array allocator. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of elements in the array. |
Invoke<T>(MemoryAllocator<T>, Int32, Boolean)
Allocates memory.
Declaration
public static MemoryOwner<T> Invoke<T>(this MemoryAllocator<T> allocator, int length, bool exactSize)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryAllocator<T> | allocator | The memory allocator. |
| Int32 | length | The number of items in the rented memory. |
| Boolean | exactSize | true to ask allocator to allocate exactly |
Returns
| Type | Description |
|---|---|
| MemoryOwner<T> | The allocated memory. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items in the memory pool. |
ToAllocator<T>(ArrayPool<T>)
Converts array pool to the memory allocator.
Declaration
public static MemoryAllocator<T> ToAllocator<T>(this ArrayPool<T> pool)
Parameters
| Type | Name | Description |
|---|---|---|
| ArrayPool<T> | pool | The array pool. |
Returns
| Type | Description |
|---|---|
| MemoryAllocator<T> | The array allocator. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items in the memory pool. |
ToAllocator<T>(MemoryPool<T>)
Converts memory pool to the memory allocator.
Declaration
public static MemoryAllocator<T> ToAllocator<T>(this MemoryPool<T> pool)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryPool<T> | pool | The memory pool. |
Returns
| Type | Description |
|---|---|
| MemoryAllocator<T> | The memory allocator. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items in the memory pool. |
ToAllocator<T>(Func<Int32, IMemoryOwner<T>>)
Converts memory provider to the memory allocator.
Declaration
public static MemoryAllocator<T> ToAllocator<T>(this Func<int, IMemoryOwner<T>> provider)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Int32, IMemoryOwner<T>> | provider | The memory provider. |
Returns
| Type | Description |
|---|---|
| MemoryAllocator<T> | The memory allocator. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the items in the memory pool. |