Show / Hide Table of Contents

Class UnmanagedMemory<T>

Represents array-like unmanaged memory.

Inheritance
Object
UnmanagedMemoryHandle
UnmanagedMemory<T>
Implements
ICloneable
IEquatable<UnmanagedMemoryHandle>
IUnmanagedArray<T>
IUnmanagedMemory
IDisposable
IEnumerable<T>
Inherited Members
UnmanagedMemoryHandle.IsInvalid
UnmanagedMemoryHandle.Clear()
UnmanagedMemoryHandle.ReleaseHandle()
UnmanagedMemoryHandle.Bytes
UnmanagedMemoryHandle.AsStream()
UnmanagedMemoryHandle.ToByteArray()
UnmanagedMemoryHandle.WriteTo(Stream)
UnmanagedMemoryHandle.ReadFrom(Stream)
UnmanagedMemoryHandle.WriteToAsync(Stream)
UnmanagedMemoryHandle.ReadFromAsync(Stream)
UnmanagedMemoryHandle.WriteTo(Pointer<Byte>)
UnmanagedMemoryHandle.ReadFrom(Pointer<Byte>)
UnmanagedMemoryHandle.WriteTo(UnmanagedMemoryHandle)
UnmanagedMemoryHandle.BitwiseEquals(UnmanagedMemoryHandle)
UnmanagedMemoryHandle.BitwiseCompare(UnmanagedMemoryHandle)
UnmanagedMemoryHandle.Equals(UnmanagedMemoryHandle)
UnmanagedMemoryHandle.Equals(Object)
UnmanagedMemoryHandle.ToString()
UnmanagedMemoryHandle.GetHashCode()
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
public sealed class UnmanagedMemory<T> : UnmanagedMemoryHandle, ICloneable, IEquatable<UnmanagedMemoryHandle>, IUnmanagedArray<T>, IUnmanagedMemory, IDisposable, IEnumerable<T> where T : struct
Type Parameters
Name Description
T

The type of elements in the unmanaged memory.

Remarks

All elements are allocated in unmanaged memory not controlled by Garbage Collector. However, the unmanaged memory will be released automatically if GC collects the instance of this type.

Constructors

| Improve this Doc View Source

UnmanagedMemory()

Allocates the block of unmanaged memory which is equal to size of type T.

Declaration
public UnmanagedMemory()
| Improve this Doc View Source

UnmanagedMemory(Int32, Boolean)

Allocates the block of unmanaged memory.

Declaration
public UnmanagedMemory(int length, bool zeroMem = true)
Parameters
Type Name Description
Int32 length

The number of elements in the unmanaged memory.

Boolean zeroMem

Sets all bytes of allocated memory to zero.

Properties

| Improve this Doc View Source

Length

Gets the number of elements in the unmanaged memory.

Declaration
public int Length { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Pointer

Gets a pointer to the allocated unmanaged memory.

Declaration
public Pointer<T> Pointer { get; }
Property Value
Type Description
Pointer<T>
| Improve this Doc View Source

Size

Gets the size of allocated unmanaged memory, in bytes.

Declaration
public override long Size { get; }
Property Value
Type Description
Int64
Overrides
UnmanagedMemoryHandle.Size
| Improve this Doc View Source

Span

Gets a span from the current instance.

Declaration
public Span<T> Span { get; }
Property Value
Type Description
Span<T>

Methods

| Improve this Doc View Source

BitwiseCompare(T[])

Bitwise comparison of the memory blocks.

Declaration
public int BitwiseCompare(T[] other)
Parameters
Type Name Description
T[] other

The array to be compared.

Returns
Type Description
Int32

Comparison result which has the semantics as return type of .

| Improve this Doc View Source

BitwiseCompare(Pointer<T>)

Bitwise comparison of the memory blocks.

Declaration
public int BitwiseCompare(Pointer<T> other)
Parameters
Type Name Description
Pointer<T> other

The block of memory to be compared.

Returns
Type Description
Int32

Comparison result which has the semantics as return type of .

| Improve this Doc View Source

BitwiseEquals(T[])

Computes bitwise equality between this array and the specified managed array.

Declaration
public bool BitwiseEquals(T[] other)
Parameters
Type Name Description
T[] other

The array to be compared.

Returns
Type Description
Boolean

true, if both memory blocks have the same bytes; otherwise, false.

| Improve this Doc View Source

BitwiseEquals(Pointer<T>)

Computes bitwise equality between two blocks of memory.

Declaration
public bool BitwiseEquals(Pointer<T> other)
Parameters
Type Name Description
Pointer<T> other

The block of memory to be compared.

Returns
Type Description
Boolean

true, if both memory blocks have the same bytes; otherwise, false.

| Improve this Doc View Source

Box(T)

Allocates a new unmanaged memory and place the given value into it.

Declaration
public static UnmanagedMemory<T> Box(T value)
Parameters
Type Name Description
T value

The value to be placed into unmanaged memory.

Returns
Type Description
UnmanagedMemory<T>

The object representing allocated unmanaged memory.

| Improve this Doc View Source

Copy()

Creates bitwise copy of the unmanaged memory.

Declaration
public UnmanagedMemory<T> Copy()
Returns
Type Description
UnmanagedMemory<T>

The independent copy of unmanaged memory.

| Improve this Doc View Source

GetEnumerator()

Gets enumerator over all elements located in the unmanaged memory.

Declaration
public Pointer<T>.Enumerator GetEnumerator()
Returns
Type Description
Pointer.Enumerator<>

The enumerator over all elements in the unmanaged memory.

| Improve this Doc View Source

ReadFrom(T[])

Copies elements from the memory location to the managed array.

Declaration
public long ReadFrom(T[] source)
Parameters
Type Name Description
T[] source

The source array.

Returns
Type Description
Int64

The actual number of copied elements.

| Improve this Doc View Source

ReadFrom(T[], Int64, Int64)

Copies elements from the specified array into the memory block identified by this object.

Declaration
public long ReadFrom(T[] source, long offset, long count)
Parameters
Type Name Description
T[] source

The source array.

Int64 offset

The position in the source array from which copying begins.

Int64 count

The number of elements of type T to be copied.

Returns
Type Description
Int64

Actual number of copied elements.

| Improve this Doc View Source

ReadFrom(Pointer<T>)

Copies bytes from the source memory to the memory identified by this object.

Declaration
public void ReadFrom(Pointer<T> source)
Parameters
Type Name Description
Pointer<T> source

The pointer to the source unmanaged memory.

| Improve this Doc View Source

Reallocate(Int32)

Resizes a block of memory represented by this instance.

Declaration
public void Reallocate(int length)
Parameters
Type Name Description
Int32 length

The new number of elements in the unmanaged array.

| Improve this Doc View Source

ToArray()

Copies elements from the unmanaged array into managed heap.

Declaration
public T[] ToArray()
Returns
Type Description
T[]

The array allocated in managed heap containing copied elements from unmanaged memory.

| Improve this Doc View Source

WriteTo(T[])

Copies elements from the memory location to the managed array.

Declaration
public long WriteTo(T[] destination)
Parameters
Type Name Description
T[] destination

The destination array.

Returns
Type Description
Int64

The actual number of copied elements.

| Improve this Doc View Source

WriteTo(T[], Int64, Int64)

Copies elements from the memory location to the managed array.

Declaration
public long WriteTo(T[] destination, long offset, long count)
Parameters
Type Name Description
T[] destination

The destination array.

Int64 offset

The position in the destination array from which copying begins.

Int64 count

The number of array elements to be copied.

Returns
Type Description
Int64

The actual number of copied elements.

| Improve this Doc View Source

WriteTo(Pointer<T>)

Copies elements from the current memory location to the specified memory location.

Declaration
public void WriteTo(Pointer<T> destination)
Parameters
Type Name Description
Pointer<T> destination

The target memory location.

| Improve this Doc View Source

WriteTo(UnmanagedMemory<T>)

Copies elements from the current memory location to the specified memory location.

Declaration
public long WriteTo(UnmanagedMemory<T> destination)
Parameters
Type Name Description
UnmanagedMemory<T> destination

The target memory location.

Returns
Type Description
Int64

The actual number of copied elements.

Operators

| Improve this Doc View Source

Implicit(UnmanagedMemory<T> to Pointer<T>)

Gets a pointer to the allocated unmanaged memory.

Declaration
public static implicit operator Pointer<T>(UnmanagedMemory<T> owner)
Parameters
Type Name Description
UnmanagedMemory<T> owner

The owner of allocated unmanaged memory.

Returns
Type Description
Pointer<T>
| Improve this Doc View Source

Implicit(UnmanagedMemory<T> to Span<T>)

Gets a span from the specified instance.

Declaration
public static implicit operator Span<T>(UnmanagedMemory<T> owner)
Parameters
Type Name Description
UnmanagedMemory<T> owner

The owner of allocated unmanaged memory.

Returns
Type Description
Span<T>

Implements

ICloneable
IEquatable<>
IUnmanagedArray<T>
IUnmanagedMemory
IDisposable
IEnumerable<>

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX