Table of Contents

Struct PinnedMemoryHandle<T>

Namespace
DotCompute.Memory
Assembly
DotCompute.Memory.dll

Represents a pinned memory handle with automatic cleanup.

public readonly struct PinnedMemoryHandle<T> : IDisposable, IEquatable<PinnedMemoryHandle<T>> where T : unmanaged

Type Parameters

T

Element type.

Implements
Inherited Members
Extension Methods

Properties

IntPtr

Gets the pinned pointer as IntPtr.

public nint IntPtr { get; }

Property Value

nint

Pointer

Gets the pinned pointer.

public void* Pointer { get; }

Property Value

void*

Methods

Dispose()

Performs dispose.

public void Dispose()

Equals(PinnedMemoryHandle<T>)

Determines whether this instance is equal to another pinned memory handle. Two handles are equal if they point to the same memory location.

public bool Equals(PinnedMemoryHandle<T> other)

Parameters

other PinnedMemoryHandle<T>

The other pinned memory handle to compare.

Returns

bool

True if the handles point to the same memory; otherwise, false.

Equals(object?)

Determines whether this instance is equal to another object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare.

Returns

bool

True if the object is a PinnedMemoryHandle<T> pointing to the same memory; otherwise, false.

GetHashCode()

Returns a hash code for this pinned memory handle based on the pointer address.

public override int GetHashCode()

Returns

int

A hash code representing the pinned memory address.

Operators

operator ==(PinnedMemoryHandle<T>, PinnedMemoryHandle<T>)

Determines whether two pinned memory handles are equal.

public static bool operator ==(PinnedMemoryHandle<T> left, PinnedMemoryHandle<T> right)

Parameters

left PinnedMemoryHandle<T>

The first handle to compare.

right PinnedMemoryHandle<T>

The second handle to compare.

Returns

bool

True if the handles point to the same memory; otherwise, false.

operator !=(PinnedMemoryHandle<T>, PinnedMemoryHandle<T>)

Determines whether two pinned memory handles are not equal.

public static bool operator !=(PinnedMemoryHandle<T> left, PinnedMemoryHandle<T> right)

Parameters

left PinnedMemoryHandle<T>

The first handle to compare.

right PinnedMemoryHandle<T>

The second handle to compare.

Returns

bool

True if the handles point to different memory; otherwise, false.