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
TElement type.
- Implements
- Inherited Members
- Extension Methods
Properties
IntPtr
Gets the pinned pointer as IntPtr.
public nint IntPtr { get; }
Property Value
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
otherPinnedMemoryHandle<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
objobjectThe 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
leftPinnedMemoryHandle<T>The first handle to compare.
rightPinnedMemoryHandle<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
leftPinnedMemoryHandle<T>The first handle to compare.
rightPinnedMemoryHandle<T>The second handle to compare.
Returns
- bool
True if the handles point to different memory; otherwise, false.